Wednesday, September 17, 2014

Configure MinGW-W64+MSYS to use PuTTY Plink/Pageant

Configure MinGW-W64+MSYS to use PuTTY Plink/Pageant

I forgot to document this last time so I figured I'd post to save anybody the trouble of figuring out how to do it again.

Install Putty/Pageant/Plink


For purposes of this document we assume you installed Pageant into:

C:\tools\PuTTY\pageant.exe

Load SSH keys into Pageant


Start Pageant and load in your SSH keys.  (Quick explanation here).

Configure Windows System Environment Variables


Windows key => "Environ" => Edit the system environment variables => [Environment Variables...]

Look in System variables, modify these if they exist, otherwise add them:

GIT_SSH = "C:\tools\PuTTY\plink.exe"
SVN_SSH = "C:\tools\PuTTY\plink.exe"

Click [OK]

Open new MinTTY (or other MSYS terminal)


Close any MSYS terminal or MinTTY that you have open, and open a new one.

Confirm that everything should be working:

bash$ env | grep -i ssh
GIT_SSH=C:\tools\PuTTY\plink.exe
SVN_SSH=C:\tools\PuTTY\plink.exe

Use PuTTY to connect to the host you want to access


For each new host you must use PuTTY to connect.  This is especially important when you are using git or svn or something that doesn't directly access ssh.  If you haven't yet connected to that host with PuTTY, the connection will probably fail.

Example first Github clone


PuTTY => New Session

  Hostname: github.com
  Click [Open]

You'll get a message from Pageant, do you want to save this key?  Click [Yes]

Now you should be good to go,  you can close the PuTTY window, and go back into MinTTY and try to git clone.

$ git clone git@github.com:joyent/node
Cloning into 'node'...

Obviously you should clone a repository to which you have access.  Everything should work.

3 comments:

  1. Thank you! I've done this years before and now reinstalled system, you saved me a couple of hours!

    ReplyDelete
  2. Thanks. This solved my headaches for weeks.

    ReplyDelete
  3. FYI I combined this guide with another one (best of both worlds) and placed it here: https://serverfault.com/a/850156/137305

    ReplyDelete