【问题标题】:SSH : ssh-keygen generating rsa key, but not workingSSH:ssh-keygen 生成 rsa 密钥,但不工作
【发布时间】:2014-10-22 00:18:24
【问题描述】:

我正在使用ssh-keygen 并且没有提供密码短语,则成功生成并显示了密钥指纹。
然后我给ssh-copy-id user@localhost,然后在提供状态Number of key(s) added : 1之后提示我的用户密码。
现在,如果我在做ssh localhost,它会再次提示输入密码。
如果我这样做ssh user@localhost,它也会要求输入密码。

PS:我使用过:ssh-addsudo ufw allow 22 每次我都使用ssh localhost 时似乎没有任何工作正常@ 提示我输入密码。

[编辑]

ssh -v localhost
显示

debug1:SSH2_MSG_KEXINIT 已发送
调试 1:收到 SSH2_MSG_KEXINIT
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com 无
调试1:kex:客户端->服务器aes128-ctr hmac-md5-etm@openssh.com无
debug1:发送 SSH2_MSG_KEX_ECDH_INIT
调试 1:期待 SSH2_MSG_KEX_ECDH_REPLY
debug1:服务器主机密钥:ECDSA b2:58:a9:da:84:3f:43:1c:86:51:ba:cd:b7:88:a3:74
debug1:主机 'localhost' 已知且与 ECDSA 主机密钥匹配。
debug1:在 /home/harsh/.ssh/known_hosts:1 中找到密钥
debug1:ssh_ecdsa_verify:签名正确
debug1:SSH2_MSG_NEWKEYS 已发送
debug1:期待 SSH2_MSG_NEWKEYS
debug1:收到 SSH2_MSG_NEWKEYS
debug1:服务器不允许漫游
调试 1:已发送 SSH2_MSG_SERVICE_REQUEST
调试 1:收到 SSH2_MSG_SERVICE_ACCEPT
debug1:可以继续的身份验证:公钥、密码
debug1:下一个认证方法:publickey
debug1:提供 DSA 公钥:/home/harsh/.ssh/id_dsa
debug1:可以继续的身份验证:公钥、密码
debug1:提供 RSA 公钥:/home/harsh/.ssh/id_rsa
debug1:可以继续的身份验证:公钥、密码
debug1:尝试私钥:/home/harsh/.ssh/id_ecdsa
debug1:尝试私钥:/home/harsh/.ssh/id_ed25519
debug1:下一个认证方法:密码
苛刻@localhost 的密码:

【问题讨论】:

  • 您的公钥在.ssh/authorized_keys 文件中吗?
  • 您可以运行 ssh -v user@localhost 并检查调试输出以查看 ssh 客户端尝试了哪些私钥,以及结果如何。
  • @knittl 是的,公钥在那里
  • 尝试私钥.ssh/id_ecdsa.ssh/id_ed25519 然后显示下一个身份验证方法:密码

标签: linux ubuntu ssh


【解决方案1】:

我会检查这些:

  • 确保远程 .ssh 目录和 authorized_keys 文件具有适当的权限

    • 两者都应归您所有
    • $HOME/.ssh 上的权限应该是 0700 (rwx:---:---) 和
    • 0600 (rw-:---:---) 在 $HOME/.ssh/authorized_keys 上
  • 验证 ssh 守护进程是否允许密钥身份验证,即对于 openssh 服务器,其配置中应该有这一行:

    • PubkeyAuthentication 是

然后在启用调试输出的情况下重新运行 ssh 命令

  • ssh -v 你的主机

它将向您显示它将尝试哪些身份验证方法,即

debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Next authentication method: publickey

祝你好运! :)

【讨论】:

  • Authentications that can be continue : publickey,password debug 1 : Next authentication method: publickey 但最终它仍然在尝试私钥,然后是密码!不知道为什么。
  • 我不断收到debug1: identity file /home/yuri/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/yuri/.ssh/id_rsa-cert type -1
【解决方案2】:

我通过简单地在我的 ubuntu 机器上重新安装 ssh 设法克服了这个问题。

问题是因为ssh 在安装OS 时没有正确安装。

【讨论】:

    【解决方案3】:

    我在通过 NFS(网络文件系统)挂载 /home 目录的设置中遇到了同样的问题。贝娄命令完成了这项工作。

    [root@localhost]# setsebool -P use_nfs_home_dirs=true

    【讨论】:

      猜你喜欢
      • 2019-07-02
      • 2020-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-05
      相关资源
      最近更新 更多