|
From: <hep...@us...> - 2016-11-13 22:32:20
|
Revision: 1354
http://sourceforge.net/p/qterm/code/1354
Author: hephooey
Date: 2016-11-13 22:32:18 +0000 (Sun, 13 Nov 2016)
Log Message:
-----------
Check what kind of key files we have
Modified Paths:
--------------
trunk/qterm/src/ssh/auth.cpp
trunk/qterm/src/ssh/auth.h
Modified: trunk/qterm/src/ssh/auth.cpp
===================================================================
--- trunk/qterm/src/ssh/auth.cpp 2016-11-13 22:32:15 UTC (rev 1353)
+++ trunk/qterm/src/ssh/auth.cpp 2016-11-13 22:32:18 UTC (rev 1354)
@@ -29,12 +29,22 @@
{
SSH2Auth::SSH2Auth(QByteArray & sessionID, SSH2InBuffer * in, SSH2OutBuffer * out, QObject *parent)
- : QObject(parent), m_username(), m_method(), m_authMethod(None), m_lastTried(None), m_sessionID(sessionID), m_publicKey(), m_tries(0)
+ : QObject(parent), m_username(), m_method(), m_authMethod(None), m_lastTried(None), m_sessionID(sessionID), m_publicKey(), m_hasRSAKey(false), m_hasDSSKey(false), m_tries(0)
{
m_in = in;
m_out = out;
m_hostInfo = NULL;
+ if (QFile::exists(QDir::homePath() + "/.ssh/id_rsa.pub") &&
+ QFile::exists(QDir::homePath() + "/.ssh/id_rsa")) {
+ m_hasRSAKey = true;
+ }
+
+ if (QFile::exists(QDir::homePath() + "/.ssh/id_dsa.pub") &&
+ QFile::exists(QDir::homePath() + "/.ssh/id_dsa")) {
+ m_hasDSSKey = true;
+ }
+
connect(m_in, SIGNAL(packetReady(int)), this, SLOT(authPacketReceived(int)));
}
@@ -112,6 +122,15 @@
void SSH2Auth::failureHandler()
{
if (m_method.contains("publickey") && m_lastTried == None) {
+ if (m_authMethod == PublicKey) {
+ if (m_hasRSAKey) {
+ // Tried and failed RSA
+ m_hasRSAKey = false;
+ } else if (m_hasDSSKey) {
+ // Only try DSS if we do not have RSA
+ m_hasDSSKey = false;
+ }
+ }
m_lastTried = PublicKey;
publicKeyAuth();
} else if (m_method.contains("keyboard-interactive") && m_lastTried <= PublicKey) {
Modified: trunk/qterm/src/ssh/auth.h
===================================================================
--- trunk/qterm/src/ssh/auth.h 2016-11-13 22:32:15 UTC (rev 1353)
+++ trunk/qterm/src/ssh/auth.h 2016-11-13 22:32:18 UTC (rev 1354)
@@ -65,6 +65,8 @@
QByteArray m_sessionID;
QByteArray m_publicKey;
SSHInfo * m_hostInfo;
+ bool m_hasRSAKey;
+ bool m_hasDSSKey;
// Give keyboardAuth and passwordAuth 3 tries.
int m_tries;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|