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 2017/08/29 05:11:26 UTC
mina-sshd git commit: Detect client/server ssh(d)_config keys related
options during command line arguments parsing
Repository: mina-sshd
Updated Branches:
refs/heads/master aa551bc0e -> 1f3006b93
Detect client/server ssh(d)_config keys related options during command line arguments parsing
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/1f3006b9
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/1f3006b9
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/1f3006b9
Branch: refs/heads/master
Commit: 1f3006b93a06d6c76b98f95f0870029458ae8e83
Parents: aa551bc
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Tue Aug 29 07:58:25 2017 +0300
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Tue Aug 29 08:02:27 2017 +0300
----------------------------------------------------------------------
.../java/org/apache/sshd/client/SshClient.java | 17 ++++++++++++-----
.../java/org/apache/sshd/server/SshServer.java | 13 ++++++++++++-
2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1f3006b9/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 e4d37ab..876b2ca 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
@@ -865,7 +865,14 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
error = showError(stderr, "bad syntax for option: " + opt);
break;
}
- options.put(opt.substring(0, idx), opt.substring(idx + 1));
+
+ String optName = opt.substring(0, idx);
+ String optValue = opt.substring(idx + 1);
+ if (HostConfigEntry.IDENTITY_FILE_CONFIG_PROP.equals(optName)) {
+ identities.add(resolveIdentityFile(optValue));
+ } else {
+ options.put(optName, optValue);
+ }
} else if ("-l".equals(argName)) {
if (login != null) {
error = showError(stderr, argName + " option value re-specified: " + port);
@@ -1030,8 +1037,8 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
return provider;
}
- public static UserInteraction setupSessionUserInteraction(ClientAuthenticationManager client,
- final BufferedReader stdin, final PrintStream stdout, final PrintStream stderr) {
+ public static UserInteraction setupSessionUserInteraction(
+ ClientAuthenticationManager client, BufferedReader stdin, PrintStream stdout, PrintStream stderr) {
UserInteraction ui = new UserInteraction() {
@Override
public boolean isInteractionAllowed(ClientSession session) {
@@ -1080,8 +1087,8 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
return ui;
}
- public static ServerKeyVerifier setupServerKeyVerifier(ClientAuthenticationManager manager, Map<String, ?> options,
- final BufferedReader stdin, final PrintStream stdout, final PrintStream stderr) {
+ public static ServerKeyVerifier setupServerKeyVerifier(
+ ClientAuthenticationManager manager, Map<String, ?> options, BufferedReader stdin, PrintStream stdout, PrintStream stderr) {
ServerKeyVerifier current = manager.getServerKeyVerifier();
if (current == null) {
current = ClientBuilder.DEFAULT_SERVER_KEY_VERIFIER;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1f3006b9/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
index 3e7c523..924c6ee 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
@@ -66,6 +66,7 @@ import org.apache.sshd.server.auth.password.PasswordAuthenticator;
import org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.apache.sshd.server.config.SshServerConfigFileReader;
+import org.apache.sshd.server.config.keys.ServerIdentity;
import org.apache.sshd.server.forward.ForwardingFilter;
import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
@@ -543,7 +544,17 @@ public class SshServer extends AbstractFactoryManager implements ServerFactoryMa
error = true;
break;
}
- options.put(opt.substring(0, idx), opt.substring(idx + 1));
+
+ String optName = opt.substring(0, idx);
+ String optValue = opt.substring(idx + 1);
+ if (ServerIdentity.HOST_KEY_CONFIG_PROP.equals(optName)) {
+ if (keyFiles == null) {
+ keyFiles = new LinkedList<>();
+ }
+ keyFiles.add(optValue);
+ } else {
+ options.put(optName, optValue);
+ }
} else if (argName.startsWith("-")) {
System.err.println("illegal option: " + argName);
error = true;