ssh pageant
Created: 2016-01-03 14:07:21 -0800 Modified: 2018-09-11 09:30:17 -0700
1/3/2016
This took me several hours to figure out. In the end, the steps are really easy, but finding Windows-specific help seemed pretty hard.
Also note: I think all of this would have been trivially easy if I had just generated my private key with Linux/Unix tools instead of puttygen (which generates a PPK file (“PuTTY private key?”) that “ssh.exe” can’t use).
Installing requirements:
- First, do “where ssh.exe” to figure out where your SSH is coming from. Mine was in “C:Program Files (x86)Gitbinssh.exe”, which unfortunately was version 1.9.5. They’ve since added a 64-bit version. I uninstalled the 32-bit version (it’s listed under “Git version 1.9.5” or maybe “Git for Windows”), then I installed the 64-bit version from here: https://git-for-windows.github.io/
- Unfortunately, ssh-pageant needs custom modifications to work with MSYS2. If you try downloading the one on their page (https://github.com/cuviper/ssh-pageant), you’ll get an error about a missing msys-1.0.dll. I found this issue (https://github.com/cuviper/ssh-pageant/issues/29) with a workaround for compiling it myself, but I instead just downloaded MSYS2 from here: https://sourceforge.net/p/msys2/wiki/Home/
- pacman.exe is downloaded as part of MSYS2 and should now be on your system. You can either launch MSYS2 Shell from the Start menu or just specify its path directly:
- “C:msys64usrbinpacman.exe” -S ssh-pageant
- Verify that you have “C:msys64usrbinssh-pageant.exe” now.
Usage:
- Make sure Pageant is running and your keys have been added. Pageant is installed as part of PuTTY.
- Just launch Pageant from the Start menu.
- Right-click the Pageant icon in the system tray and go to View Keys. If your key is not in the list, then click Add Key, type in the password for the PPK, then you’re all set.
- Run C:msys64usrbinssh-pageant.exe (note: msys64usrbin is not added to your PATH automatically).
- This starts a daemon that you’ll see in Task Manager (as “ssh-pageant” obviously), so if you had it running already, it will simply start a second daemon. There’s no reason to have many of these open, so make sure you only have a single one, and if not, End Task on them all and run this step again.
- You’ll see output like this:
SSH_AUTH_SOCK=‘/tmp/ssh-RNZglF/agent.3820’; export SSH_AUTH_SOCK;
SSH_PAGEANT_PID=9256; export SSH_PAGEANT_PID;
echo ssh-pageant pid 9256;
- First, you have to realize that because it’s running from C:msys64, it’s treating “/tmp” as a real directory, but it really points to C:msys64tmp, so transform the above into the below by changing the variables into Windows-style SETs, and the directory into the full path:
set SSH_AUTH_SOCK=C:/msys64/tmp/ssh-RNZglF/agent.3820
set SSH_PAGEANT_PID=9256
- Run the above “set” statements.
- Run ssh-add with no arguments. If it succeeds, you’ll see no output.
- If you screwed up the transformation part, then you’ll see “Error connecting to agent: No such file or directory”. You should do “ls %SSH_AUTH_SOCK%” to make sure it exists.
- Now you’re ready to SSH!
- ssh user@192.168.1.1
On Windows, you can apparently make Pageant start at boot. I haven’t done this, but the link is here: https://sites.google.com/a/martianpackets.com/martianpackets/Home/puttytips—runpageantonwindowsstartup