我正在尝试在笔记本Windows 10上的ssh客户端和VMWare上安装的Ubuntu之间建立简单的SSH连接。我将libssh用于ssh支持,并使用Qt Creator作为IDE。这是一段代码:
int verbosity = SSH_LOG_PROTOCOL;
int port = 22;
ssh_session ssh = ssh_new();
if (ssh == nullptr)
{
QMessageBox::critical(this, "Error", "Something went wrong with allocation!", QMessageBox::Ok);
}
else
{
QMessageBox::information(this, "Succes", "Allocation was successful!", QMessageBox::Ok);
}
ssh_options_set(ssh, SSH_OPTIONS_USER, "root");
ssh_options_set(ssh, SSH_OPTIONS_HOST, "192.168.237.128");
ssh_options_set(ssh, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
ssh_options_set(ssh, SSH_OPTIONS_PORT, &port);
int rc = ssh_connect(ssh);
if (rc != SSH_OK)
{
QMessageBox::critical(this, "Eroare", "SSH Connection failed!", QMessageBox::Ok);
//ssh_free(ssh);
}
连接失败,并且我总是收到错误消息:“无法处理系统配置文件”。Windows和Linux之间的连接可以使用Putty / PowerShell,我在〜/ .ssh中有配置文件,并且已安装OpenSSH。我认为这是一个客户端问题,但目前我仍然处于困境。
最佳答案
如果有人面临或将要遇到此问题,我用来避免此错误的解决方法是使用SSH_OPTIONS_SSH_DIR选项设置ssh目录。
const char* sshDirectory = "path/to/.ssh/";
ssh_options_set(sshSession, SSH_OPTIONS_SSH_DIR, sshDirectory);
关于c - SSH连接失败:无法处理系统配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60858590/