使用公钥登录ssh时仍询问密码

使用公钥登录ssh时仍询问密码,ssh,Ssh,我已将公钥id_rsa.pub添加到远程/家庭/用户授权密钥。关于权限,该文件为600,父目录.ssh为700。我还修改了sshd_配置。 当我执行ssh-vv时user@remote错误如下所示 debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /home/hjjj/.ssh/identity ((nil)) debug2: key: /home/hjjj/.ss

我已将公钥id_rsa.pub添加到远程/家庭/用户授权密钥。关于权限,该文件为600,父目录.ssh为700。我还修改了sshd_配置。
当我执行
ssh-vv时user@remote
错误如下所示

debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/hjjj/.ssh/identity ((nil))
debug2: key: /home/hjjj/.ssh/id_rsa (0x55b3d8c54bc0)
debug2: key: /home/hjjj/.ssh/id_dsa ((nil))
debug2: key: /home/hjjj/.ssh/id_ecdsa ((nil))
debug3: Wrote 84 bytes for a total of 1309
debug1: Authentications that can continue: password,publickey
debug3: start over, passed a different list password,publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/hjjj/.ssh/identity
debug3: no such identity: /home/hjjj/.ssh/identity
debug1: Offering public key: /home/hjjj/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug3: Wrote 388 bytes for a total of 1697
debug1: Authentications that can continue: password,publickey
debug1: Trying private key: /home/hjjj/.ssh/id_dsa
debug3: no such identity: /home/hjjj/.ssh/id_dsa
debug1: Trying private key: /home/hjjj/.ssh/id_ecdsa
debug3: no such identity: /home/hjjj/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
123_hjjj@remote's password: 
debug3: packet_send2: adding 48 (len 65 padlen 15 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug3: Wrote 148 bytes for a total of 1845.
---编辑--- 首先谢谢。我在下面检查:我已经用非root
userA
登录了客户端,我想用非root
userB
登录远程服务器,我可以通过密码验证成功访问该服务器。我还将userA的
id\u rsa.pub
添加到userB的
授权密钥
文件中。
sshd\u配置
---

我在
/var/log
下找不到auth.log,但在
/var/log/secure
下找不到auth.log。在我执行
ssh之后userB@remote-p 9998
在客户端上,日志输出为:

sshd[22208]: Connection closed by 192.168.5.38

当您遇到ssh问题时,最好使用
-v

启动ssh 从您的日志中可以看到您提供了密钥(
提供公钥:/home/hjjj/.ssh/id\u rsa
),
但它未被接受(缺少
服务器接受密钥

客户端的下一步应该是:

  • 验证您使用的是正确的用户
  • 验证您是否正在连接到预期的服务器
然后,您应该切换到服务器:

  • 检查您的
    /etc/ssh/sshd_config
    中是否有
    PubkeyAuthentication yes
  • 检查
    /var/log/auth.log

谢谢。根据你的意见,我检查了这些问题。我已编辑问题正文并添加检查结果。请继续读单词。
/var/log/secure
似乎有点稀疏。您可以尝试
journalctl\u COMM=sshd-n50
journalctl sshd-n50
。您是否安装了防火墙或fail2ban?
sshd[22208]: Connection closed by 192.168.5.38