4

I am using Pageant on my Windows machine to manage my SSH key. I have used ssh-agent before, but since Vagrant does not use ssh but net-ssh on vagrant up/provisioning I need to have my key in Pageant to use agent forwarding there.

I heavily use my ~/.ssh/config file to configure host shortcuts, keys they should use etc.

The .ppk file that pageant uses is not compatible with the ssh client, so I can not put it in the IdentifyFile directive.

I could, of course, let my ssh-agent run, too, but this kind of duplicates everything.

How do I combine pageant with my ssh client?

To clarify what I want to do:

  1. Add my SSH-Key to Pageant
  2. Configure [email protected] in the ~/.ssh/config as 'myhost'
Host myhost
    User calo
    Hostname myhost.com
    IdentityFile ~/.ssh/myhost
  1. Open up a git bash and type ssh myhost to connect to my host without having to put down my password again, because it would be taken from the pageant.
2
  • Pageant does not/cannot use the .ssh folder in any way. Aug 18, 2016 at 10:28
  • I do not want Pageant to use it. I want...I am going to clarify my question. Stay posted.
    – func0der
    Aug 18, 2016 at 10:35

6 Answers 6

1

It can be done. You need to:

  1. create windows environment variable named GIT_SSH
  2. put the path to your plink.exe as value, for me it was:
    C:\Program Files\PuTTY\plink.exe
    
  3. logout & login (or restart your compouter)
  4. you should be done, you can confirm yourself you have set the variable right by git bash command:
    $ export
    
    (shows all env variables)
4
  • 3
    While this can be a useful information, it does not answer the question. -- How does this allow you to "use the ~/.ssh/config file with Pageant"? Nov 5, 2019 at 12:13
  • @MartinPrikryl did you read the whole description? The qeustion title is wrong, the question is inside in description "How do I combine pageant with my ssh client?", and I am exactly answering it
    – midlan
    Nov 5, 2019 at 16:01
  • 1
    Yes I did. The question title is not wrong. The question explicitly says that OP "heavily use my ~/.ssh/config file to configure host shortcuts, keys they should use etc." - Your answer does not allow that. Nov 5, 2019 at 16:08
  • 1
    The ~/.ssh/config works in git bash ssh agent by default. I assume the IdentityFile is ignored when using ssh agent. (can't confirm now, I am using single key and I don't fill the IdentityFile option)
    – midlan
    Nov 6, 2019 at 19:02
1

The usage of https://github.com/benpye/wsl-ssh-pageant solves this.

Add

IdentityAgent SSH_AUTH_SOCK

to your .ssh/config

Add the user environment variable via windows setting: Name: SSH_AUTH_SOCK Value: \.\pipe\ssh-pageant

Start: wsl-ssh-pageant.exe --winssh ssh-pageant

Now you can login in to your host via ssh in commandshell or powershell. Of cousre pageant must be running with keys already.

1

I suggest to use the OpenSSH client included in Windows, which is supported by Pageant.

  • Start Pageant with the parameter --openssh-config to generate a config file to be included in your SSH configuration: pageant.exe --openssh-config C:\Users\demouser\pageant.conf --encrypted C:\Users\demouser\.ssh\id_ed25519.ppk (--encrypted makes Pageant ask for the passphrase on first use instead of startup)
  • Add an Include instruction in your %userprofile%\.ssh\config: Include C:\Users\demouser\pageant.conf
  • Change the PATH variable in your %userprofile%\.bashrc so Git Bash uses the OpenSSH client included in Windows: export PATH="/C/Windows/System32/OpenSSH/:$PATH"

Now when you type ssh somehost in your Git Bash, Pageant will ask for your passphrase once and will remember it as long as it is running.

0

.ppk files can be easily converted to OpenSSH format using PuTTYgen's "Export" feature.

That would be your best option, considering that OpenSSH's ssh program does not speak the Pageant protocol (nor vice versa). Only PuTTY's plink, psftp, &c. can use Pageant.

In PuTTY though, similar configuration could be done by saving a 'session' in PuTTY's GUI.

3
  • Which would not help me with stuff like vagrant though, which uses ssh-agent for agent forwading. :/ And the simple truth is: I do not want to use PuTTY as my SSH client.
    – func0der
    Aug 18, 2016 at 14:12
  • 1
    Then don't use PuTTY! Like I said, you can convert the key to OpenSSH format, for loading into ssh-agent. Aug 19, 2016 at 18:47
  • You do not get that I do not have NO choice here. If I would, I'd use ssh-agent on a Linux machine, but the fact that I do not made me open this question. I know, I could use both, but as I said, I want to keep it "simple". Single point of storage in this case.
    – func0der
    Aug 22, 2016 at 9:37
0

I'm not sure this will solve your use case but using a PuTTY session worked for me in my scenario when using Mercurial.

Before: I have a working Pageant with a working ssh key and I clone from myhost using

hg clone ssh://calo@myhost//home/hg/repo

After:

hg clone ssh://host_hg//home/hg/repo

To accomplish this I created a saved session in PuTTY called host_hg where I set the "Auto-login username" to calo. You can create a new session by right-clicking the Pageant icon in the toolbar and select "New Session". Enter the Host Name and Saved Sessions name. You'll find the field "Auto-login username" in the left tree under "Connection->Data". Don't forget to Save the session.

I guess the equivalent of IdentityFile is "Private key file for authentication" found under Connection->SSH->Auth.

0

Setting GIT_SSH will tell git to use Putty plink.exe instead of the OpenSSH ssh command. This of course will work for git commands to be executed without passwords. But the ~/.ssh/config will not be respected and the ssh command i.e. in Cygwin or Git Bash will still ask for the Password of your git.

If you want to use the (OpenSSH) ssh command within the GIT Bash, you can try to use an SSH Agent that supports connecting to Pageant like this one: https://github.com/cuviper/ssh-pageant

Using this you should be able to use Pageant as SSH Agent and therefore don't need to enter your credentials once you enter ssh and at the same time the content of your ~/.ssh/config file will be respected.

Please note: If you already set GIT_SSH to plink, git will still ignore your ~/.ssh/config file, as Putty doesn't use it.

So make sure that you don't have this variable set (or set to OpenSSH), if you want to use this custom SSH Agent also together with git.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .