Java 使用j2ssh maverick连接到ssh而不进行主机密钥验证
我有两台具有可信连接的服务器。我想通过ssh连接通过SFTP传输文件,无需验证主机密钥 我正在使用Java1.7和RedhatLinux操作系统 之前我使用的是j2ssh-core0.2.9.jar,在其中我可以连接到ssh,如下所示:Java 使用j2ssh maverick连接到ssh而不进行主机密钥验证,java,ssh,sftp,j2ssh,Java,Ssh,Sftp,J2ssh,我有两台具有可信连接的服务器。我想通过ssh连接通过SFTP传输文件,无需验证主机密钥 我正在使用Java1.7和RedhatLinux操作系统 之前我使用的是j2ssh-core0.2.9.jar,在其中我可以连接到ssh,如下所示: SshConnectionProperties properties = new SshConnectionProperties(); SshClient ssh = new SshClient(); properties.setHost
SshConnectionProperties properties = new SshConnectionProperties();
SshClient ssh = new SshClient();
properties.setHost(host);
properties.setPort(port);
ssh.setSocketTimeout(readTimeOut);
ssh.connect(properties,new IgnoreHostKeyVerification());
以特立独行的方式
SshConnector con = SshConnector.createInstance();
con.getContext().setHostKeyVerification(
new ConsoleKnownHostsKeyVerification());
con.getContext().setPreferredPublicKey(
Ssh2Context.PUBLIC_KEY_SSHDSS);
SocketTransport t = new SocketTransport(hostname, port);
t.setTcpNoDelay(true);
SshClient ssh = con.connect(t, username);
Ssh2Client ssh2 = (Ssh2Client) ssh;
请建议如何在j2ssh maverick中实现这一点。要在没有主机密钥验证的情况下进行连接,只需从j2ssh maverick代码段中删除以下代码即可
con.getContext().setHostKeyVerification(
new ConsoleKnownHostsKeyVerification());
但是,您正在删除验证服务器的协议的一个重要部分。让您完全接受中间人攻击。您发布的j2ssh代码有什么问题?请描述您的具体问题。@Kenster j2ssh-core0.2.9在2009年之后没有更新。所以选择了j2ssh maverick。j2ssh内核中也有一些bug,而且也不支持。