Linux学习34_ 关于linux上面ssh和sftp到某台服务器出现Permission denied, please try again.

最近在阿里云上面部署了两台服务器。服务器a(图片服务器)和服务器b(主程序),b是通过Java的jsch这个框架来往a传送图片的,但是最近发送在b上面操作sftp的时候一直在报

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. [root@iZ23h0vz72uZ ~]# sftp root@192.168.1.11  
  2. Connecting to 192.168.1.11...  
  3. root@192.168.1.11's password:   
  4. Permission denied, please try again.  


一直报以上的错误,通过各种配置都不行,最后调通了b到a无密码登录的,但是通过程序java的jsch去连的时候会报

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: Failed password for ftp_1 from *.*.*.* port 33118 ssh2  
  2. Apr 20 10:55:35 iZ2380a1u1tZ sshd[27327]: Received disconnect from *.*.*.*: 3: com.jcraft.jsch.JSchException: Auth fail  


以下是sshd的debug日志

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1.  : Apr 20 10:55:33 iZ2380a1u1tZ sshd[25188]: debug1: Forked child 27326.  
  2. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: Set /proc/self/oom_score_adj to 0  
  3. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: rexec start in 4 out 4 newsock 4 pipe 6 sock 7  
  4. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: inetd sockets after dupping: 3, 3  
  5. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: Connection from 192.168.1.11 port 33118  
  6. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: Client protocol version 2.0; client software version JSCH-0.1.51  
  7. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: no match: JSCH-0.1.51  
  8. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: Enabling compatibility mode for protocol 2.0  
  9. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: Local version string SSH-2.0-OpenSSH_5.3  
  10. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: permanently_set_uid: 74/74  
  11. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: list_hostkey_types: ssh-rsa,ssh-dss  
  12. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: SSH2_MSG_KEXINIT sent  
  13. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: SSH2_MSG_KEXINIT received  
  14. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: kex: client->server aes128-ctr hmac-md5 none  
  15. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: kex: server->client aes128-ctr hmac-md5 none  
  16. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: expecting SSH2_MSG_KEXDH_INIT  
  17. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: SSH2_MSG_NEWKEYS sent  
  18. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: expecting SSH2_MSG_NEWKEYS  
  19. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: SSH2_MSG_NEWKEYS received  
  20. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: KEX done  
  21. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: userauth-request for user test_1 service ssh-connection method none  
  22. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: attempt 0 failures 0  
  23. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: PAM: initializing for "test_1"  
  24. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: userauth-request for user test_1 service ssh-connection method gssapi-with-mic  
  25. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: attempt 1 failures 0  
  26. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: PAM: setting PAM_RHOST to "192.168.1.11"  
  27. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: PAM: setting PAM_TTY to "ssh"  
  28. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27326]: debug1: Unspecified GSS failure.  Minor code may provide more information\nKey table file '/etc/krb5.keytab' not found\n  
  29. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: userauth-request for user test_1 service ssh-connection method password  
  30. Apr 20 10:55:33 iZ2380a1u1tZ sshd[27327]: debug1: attempt 2 failures 0  
  31. Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: debug1: PAM: password authentication failed for test_1: Authentication failure  
  32. Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: Failed password for test_1 from 192.168.1.11 port 33118 ssh2  
  33. Apr 20 10:55:35 iZ2380a1u1tZ sshd[27327]: Received disconnect from 192.168.1.11: 3: com.jcraft.jsch.JSchException: Auth fail  
  34. Apr 20 10:55:35 iZ2380a1u1tZ sshd[27327]: debug1: do_cleanup  
  35. Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: debug1: do_cleanup  
  36. Apr 20 10:55:35 iZ2380a1u1tZ sshd[27326]: debug1: PAM: cleanup  

以下是/etc/sshd/sshd_config的配置


[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. #       $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $  
  2.   
  3. # This is the sshd server system-wide configuration file.  See  
  4. # sshd_config(5) for more information.  
  5.   
  6. # This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin  
  7.   
  8. # The strategy used for options in the default sshd_config shipped with  
  9. # OpenSSH is to specify options with their default value where  
  10. # possible, but leave them commented.  Uncommented options change a  
  11. # default value.  
  12.   
  13. #Port 22  
  14. #ListenAddress 0.0.0.0  
  15. #ListenAddress ::  
  16.   
  17. # Disable legacy (protocol version 1) support in the server for new  
  18. # installations. In future the default will change to require explicit  
  19. # activation of protocol 1  
  20. Protocol 2  
  21.   
  22. # HostKey for protocol version 1  
  23. #HostKey /etc/ssh/ssh_host_key  
  24. # HostKeys for protocol version 2  
  25. #HostKey /etc/ssh/ssh_host_rsa_key  
  26. #HostKey /etc/ssh/ssh_host_dsa_key  
  27.   
  28. # Lifetime and size of ephemeral version 1 server key  
  29. #KeyRegenerationInterval 1h  
  30. #ServerKeyBits 1024  
  31.   
  32. # Logging  
  33. # obsoletes QuietMode and FascistLogging  
  34. LogLevel debug  
  35.   
  36. # Authentication:  
  37.   
  38. #LoginGraceTime 2m  
  39. #StrictModes yes  
  40. #MaxAuthTries 6  
  41. #MaxSessions 10  
  42.   
  43. #RSAAuthentication yes  
  44. #PubkeyAuthentication yes  
  45. #AuthorizedKeysFile     .ssh/authorized_keys  
  46. #AuthorizedKeysCommand none  
  47. #AuthorizedKeysCommandRunAs nobody  
  48.   
  49. # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts  
  50. #RhostsRSAAuthentication no  
  51. # similar for protocol version 2  
  52. #HostbasedAuthentication no  
  53. # Change to yes if you don't trust ~/.ssh/known_hosts for  
  54. # RhostsRSAAuthentication and HostbasedAuthentication  
  55. #IgnoreUserKnownHosts no  
  56. # Don't read the user's ~/.rhosts and ~/.shosts files  
  57. #IgnoreRhosts yes  
  58.   
  59. # To disable tunneled clear text passwords, change to no here!  
  60. #PermitEmptyPasswords no  
  61.   
  62. # Change to no to disable s/key passwords  
  63. #ChallengeResponseAuthentication yes  
  64. ChallengeResponseAuthentication no  
  65.   
  66. # Kerberos options  
  67. #KerberosAuthentication no  
  68. #KerberosOrLocalPasswd yes  
  69. #KerberosTicketCleanup yes  
  70. #KerberosGetAFSToken no  
  71. #KerberosUseKuserok yes  
  72.   
  73. # GSSAPI options  
  74. GSSAPIAuthentication no  
  75. #GSSAPIAuthentication yes  
  76. #GSSAPICleanupCredentials yes  
  77. GSSAPICleanupCredentials yes  
  78. #GSSAPIStrictAcceptorCheck yes  
  79. #GSSAPIKeyExchange no  
  80.   
  81. # Set this to 'yes' to enable PAM authentication, account processing,   
  82. # and session processing. If this is enabled, PAM authentication will   
  83. # be allowed through the ChallengeResponseAuthentication and  
  84. # PAM authentication via ChallengeResponseAuthentication may bypass  
  85. # If you just want the PAM account and session checks to run without  
  86. # and ChallengeResponseAuthentication to 'no'.  
  87. #UsePAM no  
  88. UsePAM yes  
  89.   
  90. # Accept locale-related environment variables  
  91. AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES  
  92. AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT  
  93. AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE  
  94. AcceptEnv XMODIFIERS  
  95.   
  96. #AllowAgentForwarding yes  
  97. #AllowTcpForwarding yes  
  98. #GatewayPorts no  
  99. #X11Forwarding no  
  100. X11Forwarding yes  
  101. #X11DisplayOffset 10  
  102. #X11UseLocalhost yes  
  103. #PrintMotd yes  
  104. #PrintLastLog yes  
  105. #TCPKeepAlive yes  
  106. UseLogin yes  
  107. #UsePrivilegeSeparation yes  
  108. #PermitUserEnvironment no  
  109. #Compression delayed  
  110. #ClientAliveInterval 0  
  111. #ClientAliveCountMax 3  
  112. #ShowPatchLevel no  
  113. #PidFile /var/run/sshd.pid  
  114. #MaxStartups 10:30:100  
  115. #PermitTunnel no  
  116. #ChrootDirectory none  
  117.   
  118. # no default banner path  
  119. #Banner none  
  120.   
  121. # override default of no subsystems  
  122. Subsystem       sftp    /usr/libexec/openssh/sftp-server  
  123. #Subsystem sftp internal-sftp  
  124.   
  125. # Example of overriding settings on a per-user basis  
  126. #Match User anoncvs  
  127. #       X11Forwarding no  
  128. #       AllowTcpForwarding no  
  129. #       ForceCommand cvs server  
  130. #UseDNS yes  
  131. UseDns no  
  132. AddressFamily inet  
  133. PermitRootLogin yes  
  134. SyslogFacility AUTHPRIV  
  135. PasswordAuthentication yes  

最后是把use PAM设置成为no才能正常的sftp和ssh到a服务器,真是太辛苦了,整整搞了一天

原文来自:http://blog.csdn.net/qq_22929803/article/details/51202082

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值