我一直在尝试使用 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
私钥。