java.io.IOException: Password authentication failed

最近在项目中要用到java调用远程shell脚本,从网上下载了ssh2,去执行方法的时候,出现了如下错误:
java.io.IOException: Password authentication failed.
at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:300)
at ch.ethz.ssh2.Connection.authenticateWithPassword(Connection.java:309)
at test.demo.TestSSH.main(TestSSH.java:19)
Caused by: java.io.IOException: Authentication method password not supported by the server at this stage.
at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:270)
... 2 more
错误原因是:linux服务器中的ssh服务被禁用了,所以我们只需要将Linux下的ssh服务开启即可,下面介绍如何开启ssh服务

介绍OpenSUSE 11.1中如何开启ssh服务
详细内容
打开系统菜单中的super命令控制台,

类似windows下的cmd窗口,

照以下步骤输入命令并操作:

1、修改sshd_config文件,命令为:vi /etc/ssh/sshd_config

2、将#PasswordAuthentication no的注释去掉,并且将NO修改为YES

3、将#PermitRootLogin yes的注释去掉

4、重新启动SSH服务,命令为:/etc/init.d/sshd restart

5、验证SSH服务状态,命令为:/etc/init.d/sshd status

猜你喜欢

转载自zoouyong20.iteye.com/blog/1122323