I have generated a key pair with ssh-keygen
. I now want to use the same key pair with PuTTY-based applications.
Because I'm working in a CLI environment, I want to convert the key to the .ppk
format from within this environment.
Apparently, you can use puttygen openssh_private_key -o output_filename.ppk
on UNIX-like environments. But the Windows version of puttygen
will just load the key and prompt you to use the GUI to export the key.
Batch mode for Windows PuTTYgen suggests that this simply is not currently possible, at least with puttygen
. I'd gladly accept and option that uses other means though.
How can I convert the key from the command line?
Answer
WinSCP supports command-line conversion of private keys from the OpenSSH (or ssh.com) format to the PuTTY .ppk
format.
Use the /keygen
switch:
winscp.com /keygen mykey.pem /output=mykey.ppk
(I'm the author of WinSCP)
Or, you can compile/run the Unix command-line puttygen
using the Cygwin.
Or build your own tool from PuTTY code. It's open-source. It is rather easy (that's basically what WinSCP does).
Use the import_ssh2
to load the .pem
:
ssh2_userkey *import_ssh2(const Filename *filename, int type,
char *passphrase, const char **errmsg_p);
Use the ssh2_save_userkey
to save it as the .ppk
:
bool ssh2_save_userkey(
const Filename *filename, ssh2_userkey *key, char *passphrase);
Comments
Post a Comment