How do I get WinSCP to connect to an SSH server with a private key that I specify.
I don't see the option.
For example, I have a private key I created with SSH in cygwin. (id_rsa)
$ ls ~/.ssh -l -rw------- 1 user None 2602 Dec 24 17:26 id_rsa -rw-r--r-- 1 user None 570 Dec 24 17:28 id_rsa.pub -rw-r--r-- 1 user None 4562 Apr 27 08:03 known_hosts $ cat .ssh/id_rsa -----BEGIN OPENSSH PRIVATE KEY----- b3Blb...........wcm9ib29rMQECAw== -----END OPENSSH PRIVATE KEY-----And I have already added the Public key (id_rsa.pub), to
authorized_keyson the server.
2 Answers
On the WinSCP Login dialog, click the Advanced button, go to SSH > Authentication, and in the Private key file box, browse for your private key file:
See also
If you do not have your key in the PuTTY .ppk format, you will need to change the file filter to All private key files; once you select the SSH key, WinSCP will offer to convert the key for you, saving a copy of the key in .ppk format.
(Martin's answer is quicker than this answer)
The easiest way is to ensure you can connect in PuTTY first since it's very similar to WinSCP:
PuTTY requires the key to be a .ppk [Putty Private Key]
- How to convert an RSA key (like OpenSSH uses) to a
.ppkwith PuTTYgen:- File → Load private key → Change to show all files
- Choose
id_rsato load the RSA key → File → Save private key
- In PuTTY:
- Connection → SSH → Auth → Private key file for authentication → Choose the
.ppk - PuTTY asks you to specify the username, which is the same username as with OpenSSH [SSH used in cygwin when executing
ssh user@ip] - Now put PuTTY aside, as it helps to know how to connect with PuTTY
- Connection → SSH → Auth → Private key file for authentication → Choose the
At the WinSCP login screen, go to New Site
- File protocol → SCP [file transfer over SSH]
- Advanced → SSH → Authentication → Load private key → Choose
.ppkcreated above
PuTTYgen is used to convert an RSA key to a.ppk, which is done in the same way I described above