diff --git a/ext/qsshsocket/qsshsocket.cpp b/ext/qsshsocket/qsshsocket.cpp index 89de9c6..cf3eae5 100644 --- a/ext/qsshsocket/qsshsocket.cpp +++ b/ext/qsshsocket/qsshsocket.cpp @@ -76,6 +76,8 @@ void QSshSocket::run() { m_session = ssh_new(); + int timeout_sec = 30; + //set logging to verbose so all errors can be debugged if crash happens int verbosity = SSH_LOG_NOLOG; @@ -84,6 +86,7 @@ void QSshSocket::run() ssh_options_set(m_session, SSH_OPTIONS_USER, m_user.toUtf8().data()); ssh_options_set(m_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); ssh_options_set(m_session, SSH_OPTIONS_PORT, &m_port); + ssh_options_set(m_session, SSH_OPTIONS_TIMEOUT, &timeout_sec); // try to connect given host, user, port int connectionResponse = ssh_connect(m_session); @@ -160,6 +163,24 @@ void QSshSocket::run() error(KeyAuthenticationFailedError); } } + // Just try ssh-agent and default keys + else if (m_user != "") + { + int rc; + + rc = ssh_userauth_publickey_auto(m_session, + m_user.toUtf8().data(), + NULL); + if (rc == SSH_OK) { + loginSuccessful(); + m_loggedIn = true; + } else { + m_user = ""; + m_key = ""; + m_key_passphrase = ""; + error(KeyAuthenticationFailedError); + } + } } // if all ssh setup has been completed, check to see if we have any commands to execute else if (!m_currentOperation.executed)