libssh trying to authenticate with public and private keys

2.5k views Asked by At

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.

2

There are 2 answers

0
Martin Prikryl On BEST ANSWER

Use the ssh_userauth_privatekey_file instead, or see a libssh code for how it is implemented (it calls the ssh_userauth_pubkey internally).

int ssh_userauth_privatekey_file(ssh_session session,
                                 const char *username,
                                 const char *filename,
                                 const char *passphrase);

You will need to convert your .ppk file to OpenSSH format using PuTTYgen (Conversions > Export OpenSSH key).

0
Shilpa Kewlani On

Please go through the below link, it has the solution for this problem:

http://social.technet.microsoft.com/wiki/contents/articles/20974.biztalk-server-2010-how-to-use-blogical-sftp-adapter.aspx

  1. Just install a Bitwise SSG server.
  2. Go to Manage host.
  3. Import your private key.
  4. Then select the same private key and click on "export" option.
  5. Pop-up will ask the format for key to export, click on openSSH format.
  6. Save the new key with extension as .ppk in your local.
  7. Now give this key as input to BizTalk SFTP adapter. It will connect to the SFTP Server.