I've been trying to use libssh to connect to a server and download files via SFTP. I have a PuTTY private key file containing 6 lines of key for the public key and 12 for the private key yet I can't find any decent help or documentation of taking these keys and using them to authenticate a connection to the server. Does anybody know how to do this?
So far the only options for authentication I can find are what I found in the libssh header file:
LIBSSH_API int ssh_userauth_pubkey(ssh_session session, const char *username, ssh_string publickey, ssh_private_key privatekey);
However, I don't know how a key from a PuTTY .ppk
file can translate into an ssh_string
for the public key or a ssh_private_key
for the private key.
Use the
ssh_userauth_privatekey_file
instead, or see a libssh code for how it is implemented (it calls thessh_userauth_pubkey
internally).You will need to convert your
.ppk
file to OpenSSH format using PuTTYgen (Conversions > Export OpenSSH key).