2013-11-26 19 views
0

我正在使用ganymed-ssh2來執行xml配置文件中提供的命令的遠程執行。它適用於大多數服務器,除了某些地方我收到以下錯誤。使用ganymed-ssh2 >>出現錯誤「此階段服務器不支持身份驗證方法密碼」

java.io.IOException:密碼驗證失敗。在 ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:300) 在 ch.ethz.ssh2.Connection.authenticateWithPassword(Connection.java:309) 在 GenericAccessOnly.GenericAccessOnly.Access(GenericAccessOnly。 java:260) at GenericAccessOnly.GenericAccessOnly.main(GenericAccessOnly.java:190) 導致:java.io.IOException:此階段服務器支持的驗證方法密碼不是 。在 ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:270) ... 3個

在這方面將肯定有很大的幫助任何幫助。

Regards

回答

1

嗯..這個例外真的是不言而喻,不是嗎?有問題的服務器根本不支持密碼認證。您應該實施代碼,以嘗試使用ganymed-ssh2支持的不同身份驗證方法。

ganymed-ssh2中包含示例代碼,它解釋瞭如何檢查可用的auth方法。例如:

if (connection.isAuthMethodAvailable(getUsername(), "publickey")) { 
    System.out.println("--> public key auth method supported by server"); 
} else { 
    System.out.println("--> public key auth method not supported by server"); 
} 
if (connection.isAuthMethodAvailable(getUsername(), "keyboard-interactive")) { 
    System.out.println("--> keyboard interactive auth method supported by server"); 
} else { 
    System.out.println("--> keyboard interactive auth method not supported by server"); 
} 
if (connection.isAuthMethodAvailable(getUsername(), "password")) { 
    System.out.println("--> password auth method supported by server"); 
} else { 
    System.out.println("--> password auth method not supported by server"); 
} 

這裏是examples。看看SwingShell,它不僅僅使用密碼認證。

相關問題