gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 14:28:31 24 4
gpt4 key购买 nike

我已将公钥 id_rsa.pub 添加到远程/home/user 授权 key 。关于权限这个文件是 600,父目录 .ssh 是 700。我还修改了 sshd_config。
当我执行 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_rsa.pub给用户B的 authorized_keys文件。 sshd_config曾是 - -
# Authentication:

#LoginGraceTime 2m
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody


我在 /var/log 下找不到 auth.log但是 /var/log/secure .在我执行 ssh userB@remote -p 9998 之后在客户端,日志输出为:
sshd[22208]: Connection closed by 192.168.5.38

最佳答案

当您遇到 ssh 问题时,最好使用 -v 启动 ssh。 .
从您的日志中,您可以看到您提供了您的 key (Offering public key: /home/hjjj/.ssh/id_rsa),
但它没有被接受(缺少 Server accepts key )
客户端的下一步应该是:

  • 验证您使用的是正确的用户
  • 确认您正在连接到预期的服务器

  • 然后你应该切换到服务器:
  • 检查您的 /etc/ssh/sshd_config对于 PubkeyAuthentication yes
  • 检查 /var/log/auth.log 中的条目
  • 关于使用公钥 ssh 登录仍然询问密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59407903/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com