我正在使用 ssh-keygen
并且不提供密码短语然后 key 指纹成功生成并显示。
然后我给 ssh-copy-id user@localhost
然后在提供它后提示我的用户密码状态 Number of key(s) added : 1
.
现在,如果我正在执行 ssh localhost
,它会再次提示输入密码。
另外,如果我执行 ssh user@localhost
,它会要求输入密码。
PS:我已经使用过:ssh-add
和 sudo ufw allow 22
每次我做 ssh localhost
似乎都没有用已提示输入密码。
[编辑]
ssh -v localhost
显示
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA b2:58:a9:da:84:3f:43:1c:86:51:ba:cd:b7:88:a3:74
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /home/harsh/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /home/harsh/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: /home/harsh/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/harsh/.ssh/id_ecdsa
debug1: Trying private key: /home/harsh/.ssh/id_ed25519
debug1: Next authentication method: password
harsh@localhost's password:
最佳答案
我会检查这些:
确保远程 .ssh 目录和 authorized_keys 文件具有适当的权限
- 两者都应该归你所有
- 在 $HOME/.ssh 上的权限应该是 0700 (rwx:---:---) 和
- $HOME/.ssh/authorized_keys 上的 0600 (rw-:---:---)
验证 ssh 守护进程是否允许 key 验证,即对于 openssh 服务器,其配置中应该有这一行:
- 公钥认证是
然后在启用调试输出的情况下重新运行 ssh 命令
- ssh -v 你的主机
它将向您展示它将要尝试的身份验证方法,即
debug1:可以继续的身份验证:publickey,gssapi-keyex,gssapi-with-mic,password
debug1:下一个认证方式:publickey
祝你好运! :)
关于linux - SSH : ssh-keygen generating rsa key, 但不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25543666/