0

我一直在尝试使用 libssh 连接到服务器并通过 SFTP 下载文件。我有一个 PuTTY 私钥文件,其中包含 6 行公钥和 12 行私钥,但我找不到任何体面的帮助或文档来获取这些密钥并使用它们来验证与服务器的连接。有人知道怎么做这个吗?

到目前为止,我能找到的唯一身份验证选项是我在 libssh 头文件中找到的:

LIBSSH_API int ssh_userauth_pubkey(ssh_session session, const char *username, ssh_string publickey, ssh_private_key privatekey);

但是,我不知道 PuTTY.ppk文件中的密钥如何转换为ssh_string公钥或ssh_private_key私钥。

4

2 回答 2

3

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).

于 2014-11-13T07:41:22.020 回答
0

请通过以下链接,它有解决这个问题的方法:

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

  1. 只需安装 Bitwise SSG 服务器。
  2. 转到管理主机。
  3. 导入您的私钥。
  4. 然后选择相同的私钥并单击“导出”选项。
  5. 弹出窗口会询问导出密钥的格式,点击 openSSH 格式。
  6. 将扩展名为 .ppk 的新密钥保存在本地。
  7. 现在将此密钥作为 BizTalk SFTP 适配器的输入。它将连接到 SFTP 服务器。
于 2015-11-23T12:50:03.343 回答