You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2015/12/09 16:45:32 UTC
mina-sshd git commit: Added more details log messages of the user
authentication process
Repository: mina-sshd
Updated Branches:
refs/heads/master 0371baefc -> 07d57fcc3
Added more details log messages of the user authentication process
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/07d57fcc
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/07d57fcc
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/07d57fcc
Branch: refs/heads/master
Commit: 07d57fcc35784ee0e805d1e83c895a2f581125fd
Parents: 0371bae
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Wed Dec 9 17:45:22 2015 +0200
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Wed Dec 9 17:45:22 2015 +0200
----------------------------------------------------------------------
.../java/org/apache/sshd/client/SshClient.java | 2 +
.../org/apache/sshd/client/auth/UserAuth.java | 6 +++
.../sshd/client/auth/UserAuthPassword.java | 5 +++
.../sshd/client/auth/UserAuthPublicKey.java | 4 +-
.../config/keys/ClientIdentitiesWatcher.java | 2 +-
.../client/session/ClientUserAuthService.java | 44 ++++++++++++++++----
6 files changed, 51 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/07d57fcc/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index 02f7db2..265fe3c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -793,6 +793,8 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
}
}
+ //////////////////////////////////////////////////////////////////////////
+
public static void main(String[] args) throws Exception {
Handler fh = new ConsoleHandler();
fh.setLevel(Level.FINEST);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/07d57fcc/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
index 5bf1037..09fca32 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuth.java
@@ -34,6 +34,12 @@ public interface UserAuth extends ClientSessionHolder, UserAuthInstance<ClientSe
void init(ClientSession session, String service, Collection<?> identities) throws Exception;
+ /**
+ * @param buffer The {@link Buffer} to process - {@code null} if not a response buffer
+ * @return {@code true} if request handled - {@code false} if the next authentication
+ * mechanism should be used
+ * @throws Exception
+ */
boolean process(Buffer buffer) throws Exception;
void destroy();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/07d57fcc/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
index 450c915..3737b24 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
@@ -74,6 +74,11 @@ public class UserAuthPassword extends AbstractUserAuth {
sendPassword(buffer, session, current, current);
return true;
}
+
+ if (log.isDebugEnabled()) {
+ log.debug("process({}@{})[{}] no more passwords to send", username, session, service);
+ }
+
return false;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/07d57fcc/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
index db84aaf..2adbe03 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
@@ -117,7 +117,7 @@ public class UserAuthPublicKey extends AbstractUserAuth {
String algo = KeyUtils.getKeyType(key);
String name = getName();
if (log.isDebugEnabled()) {
- log.debug("process({}@{})[{}] Send SSH_MSG_USERAUTH_REQUEST request {} type={} - fingerprint={}",
+ log.debug("process({}@{})[{}] send SSH_MSG_USERAUTH_REQUEST request {} type={} - fingerprint={}",
username, session, service, name, algo, KeyUtils.getFingerPrint(key));
}
@@ -144,7 +144,7 @@ public class UserAuthPublicKey extends AbstractUserAuth {
String algo = KeyUtils.getKeyType(key);
String name = getName();
if (log.isDebugEnabled()) {
- log.debug("process({}@{})[{}] Send SSH_MSG_USERAUTH_REQUEST reply {} type={} - fingerprint={}",
+ log.debug("process({}@{})[{}] send SSH_MSG_USERAUTH_REQUEST reply {} type={} - fingerprint={}",
username, session, service, name, algo, KeyUtils.getFingerPrint(key));
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/07d57fcc/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
index e0d930a..7d1aca0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
@@ -80,7 +80,7 @@ public class ClientIdentitiesWatcher extends AbstractKeyPairProvider implements
KeyPair kp = p.getClientIdentity();
if (kp == null) {
if (log.isDebugEnabled()) {
- log.debug("loadKeys({}) no key loaded");
+ log.debug("loadKeys({}) no key loaded", p);
}
continue;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/07d57fcc/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
index 1e3ca06..49bd727 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
@@ -122,7 +122,7 @@ public class ClientUserAuthService extends AbstractCloseable implements Service,
ClientSession session = getClientSession();
String username = session.getUsername();
if (log.isDebugEnabled()) {
- log.debug("auth({})[{}] Send SSH_MSG_USERAUTH_REQUEST for 'none'", session, service);
+ log.debug("auth({})[{}] send SSH_MSG_USERAUTH_REQUEST for 'none'", session, service);
}
Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, username.length() + service.length() + Integer.SIZE);
@@ -174,7 +174,7 @@ public class ClientUserAuthService extends AbstractCloseable implements Service,
if (cmd == SshConstants.SSH_MSG_USERAUTH_SUCCESS) {
if (log.isDebugEnabled()) {
log.debug("processUserAuth({}) SSH_MSG_USERAUTH_SUCCESS Succeeded with {}",
- session, userAuth);
+ session, (userAuth == null) ? "<unknown>" : userAuth.getName());
}
if (userAuth != null) {
try {
@@ -207,7 +207,8 @@ public class ClientUserAuthService extends AbstractCloseable implements Service,
}
}
}
- tryNext();
+
+ tryNext(cmd);
return;
}
@@ -215,27 +216,52 @@ public class ClientUserAuthService extends AbstractCloseable implements Service,
throw new IllegalStateException("Received unknown packet: " + SshConstants.getCommandMessageName(cmd));
}
+ if (log.isDebugEnabled()) {
+ log.debug("processUserAuth({}) delegate processing of {} to {}",
+ session, SshConstants.getCommandMessageName(cmd), userAuth.getName());
+ }
+
buffer.rpos(buffer.rpos() - 1);
if (!userAuth.process(buffer)) {
- tryNext();
+ tryNext(cmd);
}
}
- protected void tryNext() throws Exception {
+ protected void tryNext(int cmd) throws Exception {
ClientSession session = getClientSession();
// Loop until we find something to try
while (true) {
if (userAuth == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("tryNext({}) starting authentication mechanisms: client={}, server={}",
+ session, clientMethods, serverMethods);
+ }
currentMethod = 0;
} else if (!userAuth.process(null)) {
- userAuth.destroy();
+ if (log.isDebugEnabled()) {
+ log.debug("tryNext({}) no initial request sent by method={}", session, userAuth.getName());
+ }
+
+ try {
+ userAuth.destroy();
+ } finally {
+ userAuth = null;
+ }
+
currentMethod++;
} else {
+ if (log.isDebugEnabled()) {
+ log.debug("tryNext({}) successfully processed initial buffer by method={}", session, userAuth.getName());
+ }
return;
}
- while (currentMethod < clientMethods.size() && !serverMethods.contains(clientMethods.get(currentMethod))) {
- currentMethod++;
+ String method = null;
+ for (; currentMethod < clientMethods.size(); currentMethod++) {
+ method = clientMethods.get(currentMethod);
+ if (serverMethods.contains(method)) {
+ break;
+ }
}
if (currentMethod >= clientMethods.size()) {
@@ -249,11 +275,11 @@ public class ClientUserAuthService extends AbstractCloseable implements Service,
return;
}
- String method = clientMethods.get(currentMethod);
userAuth = NamedFactory.Utils.create(authFactories, method);
if (userAuth == null) {
throw new UnsupportedOperationException("Failed to find a user-auth factory for method=" + method);
}
+
if (log.isDebugEnabled()) {
log.debug("tryNext({}) attempting method={}", session, method);
}