Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring msysgit to use putty/plink

Apologies in advance for the basic question - I'm new to git and am sure that I'm missing something super easy that someone could answer very quickly.

During the msysgit installation I specified that I would like to use PLink instead of OpenSSH as my secure shell client program. The environment variable 'GIT_SSH' is set to 'C:\Program Files (x86)\PuTTY\plink.exe', which is the correct path to plink. I've tried with and without quotes. "echo $GIT_SSH" from the bash prompt displays the correct value for the environment variable. I am also able to connect to github via SSH using putty with no problems.

After starting pagent and adding my private key, I opened a new git bash window and attempted to connect to github (github already has my public key and is correctly setup - I'm using the jquery project as a quick test). Despite specifying that I want to use PLink and apparently having the correct environment variables set, msysgit is still attempting to use the key files found in the ~/.ssh directory.

I've confirmed this by actually putting my private key in that directory and everything works perfectly (I was able to clone the jquery repository with no problems at all), but I'd really like to get this set up so I can manage my private keys through putty if possible.

Not really sure what I'm missing.. Any help is very much appreciated - thanks in advance!

like image 527
rawb Avatar asked Mar 26 '12 11:03

rawb


People also ask

What is the difference between PuTTY and plink?

Plink stands for PuTTY Link. Plink is a companion command-line utility for PuTTY. On a very high-level: Use PuTTY for interactive SSH session from your Windows to Linux Servers.

How do I set up plink?

To make a simple interactive connection to a remote server, just type plink and then the host name: C:\>plink login.example.com Debian GNU/Linux 2.2 flunky.example.com flunky login: You should then be able to log in as normal and run a session.

Does plink use SSH?

More typically Plink is used with the SSH protocol, to enable you to talk directly to a program running on the server. To do this you have to ensure Plink is using the SSH protocol. You can do this in several ways: Use the -ssh option as described in section 7.2.


2 Answers

I had similar problems and the solution is that you have to use 'plink' and not 'ssh'.

So the following commands (from the bash prompt) should work for you (assuming you've setup a GitHub SSH key):

$ echo $GIT_SSH
C:\Program Files (x86)\PuTTY\plink.exe

$ "$GIT_SSH" -V
plink: Release 0.62

$ "$GIT_SSH" -ssh [email protected]
Using username "git".
Server refused to allocate pty
Hi [your-github-username]! You've successfully authenticated, but GitHub does not provide s
hell access.

If you just run "$GIT_SSH" then it will print out the arguments that you can use. The -ssh command forces PuTTY to use the ssh protocol.

If you've got C:\Program Files (x86)\PuTTY\ in the PATH then you should just be able to run plink -ssh user@host

The reason for this is that the ssh command uses OpenSSH and OpenSSH doesn't recognise PuTTY keys.

plink.exe is actually mentioned in the first solution in the most up voted answer for Git / PuTTY configuration questions, its just hard to spot.

like image 100
icc97 Avatar answered Sep 25 '22 14:09

icc97


For me the solution was that the path needed to be specified in linux style, like so:

set GIT_SSH=/c/PuTTY/plink.exe

Which was pretty confusing since I am setting the environment variable in Windows syntax but the value is a Linux style path.

Key point is:

echo $GIT_SSH
C:\Program Files (x86)\PuTTY\plink.exe   <-- not a valid path in bash shell
like image 25
schmidlop Avatar answered Sep 23 '22 14:09

schmidlop