Search code examples
csshlibssh

SSH Connection failed : Failed to process system configuration files


I'm trying to make a simple SSH connection between ssh client which is on my notebook's Windows 10 and Ubuntu which is installed on VMWare. I use libssh for ssh support and Qt Creator as IDE. Here is the piece of code:

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);
}

Connection fails and I always get the error: "Failed to process system configuration files".Connection between Windows and Linux works with Putty/PowerShell, I have the config file in ~/.ssh and OpenSSH is installed. I think it's a client-side problem, but I am stucked at this point.


Solution

  • If anyone is facing or will face this problem, the workaround I used to avoid this error was to set the ssh directory with the SSH_OPTIONS_SSH_DIR option.

    const char* sshDirectory = "path/to/.ssh/";
    ssh_options_set(sshSession, SSH_OPTIONS_SSH_DIR, sshDirectory);