SSHJ 无法连接远程 Linux 服务器抛出 UserAuthException:用尽可用的身份验证方法
SSHJ is not able to connect remote Linux server throws UserAuthException: Exhausted available authentication methods
我正在尝试 运行 以下 Java 代码使用 sshj :-
public static void main(String[] args) throws IOException {
SSHClient ssh = new SSHClient();
ssh.loadKnownHosts();
ssh.connect("host", port);
try {
ssh.authPassword("user", "passwd");
ssh.useCompression();
final String src = System.getProperty("user.home") + File.separator + "test_file";
ssh.newSCPFileTransfer().upload(new FileSystemFile(src), "/tmp/");
} finally {
ssh.disconnect();
ssh.close();
}
}
但是抛出异常-
Exception in thread "main" net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:231)
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:206)
at net.schmizz.sshj.SSHClient.authPassword(SSHClient.java:292)
at net.schmizz.sshj.SSHClient.authPassword(SSHClient.java:262)
at net.schmizz.sshj.SSHClient.authPassword(SSHClient.java:246)
at sample.SCPUpload.main(SCPUpload.java:17)
我可以通过 Putty 使用相同的凭据连接主机。我正在使用 JDK“1.8.0_151”。这里有什么问题?
通常这意味着您的密码错误,或者不允许您使用 'password' 身份验证方法进行连接。
我正在尝试 运行 以下 Java 代码使用 sshj :-
public static void main(String[] args) throws IOException {
SSHClient ssh = new SSHClient();
ssh.loadKnownHosts();
ssh.connect("host", port);
try {
ssh.authPassword("user", "passwd");
ssh.useCompression();
final String src = System.getProperty("user.home") + File.separator + "test_file";
ssh.newSCPFileTransfer().upload(new FileSystemFile(src), "/tmp/");
} finally {
ssh.disconnect();
ssh.close();
}
}
但是抛出异常-
Exception in thread "main" net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:231)
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:206)
at net.schmizz.sshj.SSHClient.authPassword(SSHClient.java:292)
at net.schmizz.sshj.SSHClient.authPassword(SSHClient.java:262)
at net.schmizz.sshj.SSHClient.authPassword(SSHClient.java:246)
at sample.SCPUpload.main(SCPUpload.java:17)
我可以通过 Putty 使用相同的凭据连接主机。我正在使用 JDK“1.8.0_151”。这里有什么问题?
通常这意味着您的密码错误,或者不允许您使用 'password' 身份验证方法进行连接。