我正在尝试使用用户名和密码登录到我的 ssh 服务器,但在输入正确的密码后出现此错误:
Permission denied, please try again.
Run Code Online (Sandbox Code Playgroud)
不过,我可以在另一台机器上使用公钥登录,但我没有禁用常规密码身份验证。我唯一禁用的是 root 登录。
这是我的 sshd_config 文件:
# 打包生成的配置文件 # 有关详细信息,请参阅 sshd_config(5) 联机帮助页 # 我们监听哪些端口、IP 和协议 端口 22 # 使用这些选项来限制 sshd 将绑定到哪些接口/协议 #ListenAddress :: #ListenAddress 0.0.0.0 协议 2 # 协议版本 2 的主机密钥 主机密钥 /etc/ssh/ssh_host_rsa_key 主机密钥 /etc/ssh/ssh_host_dsa_key 主机密钥 /etc/ssh/ssh_host_ecdsa_key #权限分离开启安全 UsePrivilegeSeparation 是 # 临时版本 1 服务器密钥的生命周期和大小 密钥再生间隔 3600 服务器密钥位 768 # 记录 SyslogFacility AUTH 日志级别信息 # 验证: 登录GraceTime 120 PermitRootLogin 否 StrictModes 是 RSAAuthentication 是 PubkeyAuthentication 是 #AuthorizedKeysFile %h/.ssh/authorized_keys # 不要读取用户的 ~/.rhosts 和 ~/.shosts 文件 忽略Rhosts 是 # 为此,您还需要 /etc/ssh_known_hosts 中的主机密钥 RhostsRSAAuthentication 否 # 类似于协议版本 2 HostbasedAuthentication 否 # 如果您不信任 ~/.ssh/known_hosts 的 RhostsRSAAuthentication,请取消注释 #IgnoreUserKnownHosts 是 # 要启用空密码,请更改为 yes (NOT RECOMMENDED) PermitEmptyPasswords 否 # 更改为 yes 以启用质询响应密码(注意问题 # 一些 PAM 模块和线程) ChallengeResponseAuthentication 否 # 更改为 no 以禁用隧道明文密码 密码认证是 # Kerberos 选项 #KerberosAuthentication 否 #KerberosGetAFSToken 否 #KerberosOrLocalPasswd 是 #KerberosTicketCleanup 是 # GSSAPI 选项 #GSSAPIAuthentication 否 #GSSAPICleanupCredentials 是 X11转发是 X11DisplayOffset 10 PrintMotd 否 PrintLastLog 是 TCPKeepAlive 是 #UseLogin no #MaxStartups 10:30:60 #Banner /etc/issue.net # 允许客户端传递locale环境变量 AcceptEnv LANG LC_* 子系统 sftp /usr/lib/openssh/sftp-server # 将此设置为“yes”以启用 PAM 身份验证、帐户处理、 # 和会话处理。如果启用此功能,PAM 身份验证将 # 被允许通过 ChallengeResponseAuthentication 和 # 密码验证。根据您的 PAM 配置, # 通过 ChallengeResponseAuthentication 的 PAM 认证可以绕过 # “PermitRootLogin without-password”的设置。 # 如果您只想运行 PAM 帐户和会话检查 # PAM 身份验证,然后启用此但设置 PasswordAuthentication # 和 ChallengeResponseAuthentication 为“否”。 使用PAM 是 忽略UserKnownHosts 否 密码认证是
我在最近的一次尝试中添加了最后两行以使其正常工作。(我在我的其他 vps 上有它们,它们在那里工作)
这是我的用户的 ~/.ssh/ 目录列表:
ls -la /home/skerit/.ssh 共 16 个 drwx------ 2 skerit skerit 4096 2011-06-25 15:11 。 drwxr-xr-x 4 skerit skerit 4096 2011-07-07 21:05 .. -rw-r--r-- 1 skerit skerit 1882 2011-06-25 15:15authorized_keys -rw-r--r-- 1 skerit skerit 884 2011-06-23 22:59 known_hosts
这是 /usr/sbin/sshd -d 的输出:
debug1: userauth-request 用户 skrit 服务 ssh-connection 方法无 debug1: 尝试 0 失败 0 debug1:PAM:初始化“skerit” debug1:PAM:将 PAM_RHOST 设置为“82.197.70.70” debug1:PAM:将 PAM_TTY 设置为“ssh” debug1: userauth-request for user skrit service ssh-connection method publickey debug1:尝试 1 次失败 0 debug1:测试pkalg/pkblob是否可以接受 debug1:检查黑名单文件 /usr/share/ssh/blacklist.RSA-2048 debug1:检查黑名单文件 /etc/ssh/blacklist.RSA-2048 debug1:temporary_use_uid:1000/1000(e=0/0) debug1:尝试公钥文件 /home/skerit/.ssh/authorized_keys debug1: fd 4 清除 O_NONBLOCK 调试 1:restore_uid:0/0 debug1:temporary_use_uid:1000/1000(e=0/0) debug1:尝试公钥文件 /home/skerit/.ssh/authorized_keys2 debug1:无法打开授权密钥“/home/skrit/.ssh/authorized_keys2”:没有这样的文件或目录 调试 1:restore_uid:0/0 来自 82.197.70.70 端口 57154 ssh2 的 skerit 公钥失败 debug1:userauth-request 用户 skrit 服务 ssh-connection 方法密码 debug1:尝试 2 次失败 1 debug1:PAM:skrit 的密码认证失败:认证失败 来自 82.197.70.70 端口 57154 ssh2 的 skerit 密码失败
然后我尝试使用相同的用户名和密码从 ssh 服务器(本地)登录到 ssh 服务器,并且成功了。这是在 auth.log 文件中:
7 月 8 日 12:21:50 vpsnl1 sshd[27298]:debug1:无法打开密钥文件“/etc/ssh/ssh_host_ecdsa_key”:没有那个文件或目录 7 月 8 日 12:21:50 vpsnl1 sshd[27298]:错误:无法加载主机密钥:/etc/ssh/ssh_host_ecdsa_key 7 月 8 日 12:22:16 vpsnl1 sshd[27298]:pam_unix(sshd:auth):身份验证失败;日志名= uid=0 euid=0 tty=ssh ruser= rhost=82.197.70.70 用户= 斯克里特 7 月 8 日 12:23:50 vpsnl1 sshd[27439]:服务器侦听 0.0.0.0 端口 22。 7 月 8 日 12:23:50 vpsnl1 sshd[27439]:服务器侦听 :: 端口 22。 7 月 8 日 12:24:07 vpsnl1 sshd[27458]:错误:无法加载主机密钥:/etc/ssh/ssh_host_ecdsa_key 7 月 8 日 12:24:14 vpsnl1 sshd[27458]:接受来自 127.0.0.1 端口 57667 ssh2 的 skerit 密码 7 月 8 日 12:24:14 vpsnl1 sshd[27458]: pam_unix(sshd:session): 会话由 (uid=0) 为用户 skerit 打开 7 月 8 日 12:24:25 vpsnl1 sshd[27471]:收到来自 127.0.0.1 的断开连接:11:用户断开连接 7 月 8 日 12:24:25 vpsnl1 sshd[27458]:pam_unix(sshd:session):用户 skerit 的会话已关闭
您确定您尝试访问的用户帐户配置正确吗?如果您在系统上以root身份登录,您是否可以登录su用户帐户?
# su - username
Run Code Online (Sandbox Code Playgroud)
连接尝试失败后,您在日志中看到了什么?在许多系统上,sshd 将登录到某些内容/var/log/secure或/var/log/auth.log. 另外,我注意到您已PasswordAuthentication启用但已ChallengeResponseAuthentication禁用。如果启用,您是否看到相同的行为ChallengeResponseAuthentication?
当您遇到 ssh 问题时,以下是一些可使用的一般诊断步骤:
在 ssh 中启用详细诊断:
ssh -v host.example.com
Run Code Online (Sandbox Code Playgroud)
这将导致客户端在协商连接时输出各种诊断消息。这通常会提供问题的线索。
在调试模式下运行服务器。
在您的服务器上,停止 sshd,然后像这样从命令行运行它:
/usr/sbin/sshd -d
Run Code Online (Sandbox Code Playgroud)
这将产生详细的调试日志记录stderr,通常会包含有用的信息。
如果这些都不能帮助您弄清楚发生了什么,您会将输出添加到您的问题中吗?
| 归档时间: |
|
| 查看次数: |
67187 次 |
| 最近记录: |