这里的任何人都体验过 libssh C++ 包装器吗?你可以到这里我使用的是 0.6.3 版本。我按照下载文件中的安装说明来构建库。
然后我尝试在示例目录libsshpp.cpp中编译示例
#include <iostream>
#include <string>
#include <libssh/libsshpp.hpp>
int main(int argc, const char **argv){
ssh::Session session;
try {
if(argc>1)
session.setOption(SSH_OPTIONS_HOST,argv[1]);
else
session.setOption(SSH_OPTIONS_HOST,"localhost");
session.connect();
session.userauthAutopubkey();
session.disconnect();
} catch (ssh::SshException e){
std::cout << "Error during connection : ";
std::cout << e.getError() << std::endl;
}
return 0;
}
按命令 g++ -o sh libsshpp.cpp -lssh
成功,但执行时出错:./sh: symbol lookup error: ./sh: undefined symbol: ssh_userauth_publickey_auto
。希望与 libssh 合作过的人可以提供帮助!