Windows to Ubuntu git connection - windows

I've set up a git server (and gitolite) on an Ubuntu machine at Amazon. I want to interact with this server on Windows. I've installed Git for Windows (the one that comes with Visual Studio Tools for Git), but trying to access the server ends in the bash prompt telling me "Permission Denied (publickey)." I have the ssh keys from the git user on my local machine and Pageant has them loaded, but I don't see any way of telling the git client to use them. How do I tell the git command line to use my ssh keys?
Or better yet, does anyone have experience setting up Visual Studio Tools for Git to access their own personal git server rather than one at GitHub?

Ok, so turns out there is a seemingly undocumented step required to set the private keys for Git for Windows.
When Git for Windows is installed, it creates a new folder, C:\Users\[user]\.ssh. In order to set the keys to use for ssh you must copy for private ssh key for the git user to this directory and it *MUST be named "id_rsa"*. Once you have that key in that folder, you're golden.

Related

What is the correct way to configure Qt Creator to use Git?

I'm trying to use Git for Windows together with QT Creator 2.8, and failing miserably. I created a repository on bitbucket, following the bitbucket 101 tutorial and everything runs smoothly when I use Git Bash, or even Git GUI. The PATH variable is set properly, everything works outside Qt. However, when trying to configure Qt Creator, I cannot access the remote repository. The error given is:
16:25 Executing in C:\Users(...): C:\Program Files
(x86)\Git\cmd\git.exe pull The command 'C:\Program Files
(x86)\Git\cmd\git.exe' did not respond within the timeout limit (60000
ms).
Almost everything I have found tells me to configure PATH, and that should cause everything to run ok, but my PATH is set correctly (I can type ssh from the windows command prompt and it works). The Qt Creator documentation (http://qt-project.org/doc/qtcreator-2.8/creator-version-control.html) tells me that I should
"Select Tools > Options > Version Control > Git. Select the
Environment Variables and the Set "HOME" environment variable check
boxes."
The set "HOME"(...) box is checked, but there is no "Environment Variables" box. The SSH prompt command is set to C:\Program Files (x86)\Git\bin\ssh.exe, but I have tried setting it to almost every program on \git\bin and git\cmdwithout success. I have found answers here that tell me to use some version of win-ssh-askpass or win-ssh-agent, but those either require Cygwin or come from dubious sources.
What I have always done:
Install Windows (msys)git: select "only add git to PATH". This adds the Git\cmd directory to system/user-wide PATH, which is safe and very useful.
Don't enter anything in Qt Creator for git. It's in PATH, so it "just works".
Probably the most important due to the limited interactivity between git and Qt Creator: make sure your remote host is aware of your SSH key (so you don't need to enter a password, I don't think Qt Creator can handle that, and I believe this is what's going wrong in your case), and make sure your SSH config file contains the IP of the host as trusted (you can check this by running a git clone or git push from the commandline (not "git bash", just a plain cmd. This ensures your environment is similar to what Qt Creator sees.
I stress that nothing else needs setting up, so if you did, you might have broken something that should work with the above steps.
Well, maybe I have a process that seems to work.
If you use a passphrase during the generation of the keys, you'll have to type this passphrase after loading an ssh-agent and add the key to the agent.
Basically, the solution is: follow the instructions on this page:
https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html
BUT, during the generation of the keys DO NOT TYPE A PASSPHRASE.
Obviously, it's 'weaker' from a security point of view.
But, the .bashrc script will work as expected (loading the identity on git bash startup).
It's necessary to setup git\bin , git\cmd and git\usr\bin folders on the PATH environment variables, so the commands "ssh-agent", "ssh-add" will be executed.
After this, the Qt Creator should work fine for remote repository access (fetch, pull and push).

Msysgit git no longer finds ssh keys

I have an older Windows XP laptop on which I recently upgraded git to 1.8.4.msysgit.0, in order to benefit from the new cmd\git.exe instead of the older cmd\git.cmd for scripts.
After this upgrade, git asks for a password for its operations (such as cloning), where it did not before the upgrade. None the of the ssh keys were changed in any way.
The strange thing is that both
"c:\Program Files\Git\bin\ssh.exe" user#x.x.x.x
"c:\Program Files\Git\bin\git.exe" clone user#x.x.x.x:/path/to/repo
work, but
"c:\Program Files\Git\cmd\git.exe" clone user#x.x.x.x:/path/to/repo
does not.
Background information:
I tried setting %HOME%, but this did not help.
I did the exact upgrade for a win7 computer, without problems.
%PATH% includes the cmd folder of the git installation, not the bin folder.
Update1:
After messing around a bit, I noticed the ssh command also asks for a password if the %HOME% variable is set. It was set using set HOME=%HOMEDRIVE%%HOMEPATH% which resolves to c:\Documents and Settings\username.
Old versions of msysgit apparantly kept their ssh keys in the Git installation folder (c:\Documents and Settings\username\.ssh). There were 2 files in this folder (id_rsa and id_rsa.pub) that were not present in the ssh folder in the home folder. After copying these, the problem was solved.

Unable to execute git push from Package Manager Console with GitHub for Windows installed

I've set up Visual Studio 2010 in order to use Git from the Package Manager Console, more precisely:
I've installed msysgit (adding Git executables under %PATH%);
I've installed Posh Git and I've enabled it using the instructions given in this SO answer.
I've also installed GitHub for Windows for easy access to repositories hosted on GitHub.
From the Package Manager Console I am able to do all the operation locally, but when I want to push to a GitHub repository the prompt seems "blocked", I cannot kill git using the Stop button and I'm forced to close Visual Studio and to push from the Git Shell provided with GitHub for Windows.
Using Process Explorer I can see that git spawn the GitHub for Windows program to do the authentication and from there it doesn't seem to advance.
I've resolved this issue by installing the Windows Credentials Store for Git (also suggested in the TFS blog), so that it handles the authentication instead of GitHub for Windows.
Now I can do git push from Package Manager Console -- the credentials store asks for credentials the first time and then pushes correctly to GitHub.
If your repository is hosted on Team Foundation Service (not on GitHub), then besides installing the Windows Credentials Store for Git (as answered by edymtt), you must enable basic authentication before you can use the command prompt to perform Git tasks. You can set this up from your User Profile in TFS. http://msdn.microsoft.com/library/dd286572(v=vs.120).aspx

Reconcile PuTTY and OpenSSH with git remote URL

On a local development machine, I use Windows and PuTTY, with a linux server VM that I use to replicate the development environment for things like running tests and so forth. The VM (VirtualBox) uses a vboxfs share that contains my local projects.
I have set up msysgit on my machine to use PuTTY, my preferred SSH client, and that all works fine. Unfortunately, when I set a git remote URL, it has to use PuTTY's format to specify a session (ssh://<session name>/<repo>) in order for msysgit to work, which means none of the git urls work in the VM environment. This isn't a huge deal, but I was curious: Is there a way to reconcile the two configurations so I can use git commands in either environment without manually setting a remote url each time?
One work-around is to install PuTTY on your Linux machine. There are several precompiled versions out there or you can just download the official source and compile them.

How do I access a git repo on a windows share?

I want to be able to sync a work repo from my Windows 7 desktop to my Windows 7 laptop without pushing my commits to our main server. How do I do this? I can't figure out how to set up a remote path so that git can understand where it is. I generally use Git Bash for dealing with git, not the windows commandline, so the issue here is likely that I can't figure out how to write a path in Git Bash which will reference a windows share.
So, say I have a repo at (windows share path):
\\\\MyWorkPCName\dev\myrepo\
And in the command line, I can access the directories and files (albeit using pushd since cmd is stupid), how do I convert this in to a valid git remote?
While Git doesn't recognize backslashes, Windows does recognize forward slashes:
git remote add desktop //MyWorkPCName/dev/myrepo
Git Bash also lets you access windows drives using UNIX-style paths, e.g. C:\Users\bug\repo becomes /c/Users/bug/repo.

Resources