尝试 ssh 到任何服务器,即使是我授权列表中的服务器,也会导致公钥(权限被拒绝)错误或命令无限期挂起。
首次创建 ssh 密钥时,我创建了多个密钥。后来我意识到我可以用一个密钥,于是我删除了它们,但每当我尝试 ssh任何服务器我不断收到错误。
首次尝试修复:我能够通过使用 ps aux | grep ssh 和 kill xxxxx 终止 ssh 进程,然后重新启动 shell 来使其正常工作。但是,重新启动后问题再次出现,该解决方案不再起作用。
我使用的 ssh 密钥的名称不是 id_rsa,但是当我尝试 ssh -t[电子邮件保护]例如,它似乎只搜索标准 ssh 密钥名称。
我已经在我的 .ssh 目录中创建了一个定义身份的配置文件,但即使删除它之后,似乎也没有任何作用。
帮助!
第二次尝试修复:
ps aux | grep ssh
- 终止列表中的所有进程
- 重启 shell
ssh-add ~/.ssh/your-ssh-key-name
(这将失败)评估
#(这将启动 ssh-agent)ssh-agent -s
ssh-add ~/.ssh/your-ssh-key-name
#(与第 4 行相同,但这次它将成功添加你的身份)
但重新启动后,我再次遇到问题。
这是我在这里的第一个问题。如果我需要以不同的方式构建内容/提供更多信息,请告诉我。
result of ssh -vvvT [email protected] verify:
...
debug3: hostkeys_foreach: reading file "/Users/dharamkhalsa/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /Users/dharamkhalsa/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from github.com
debug3: hostkeys_foreach: reading file "/Users/dharamkhalsa/.ssh/known_hosts"
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/dharamkhalsa/.ssh/known_hosts:1
Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts.
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /Users/dharamkhalsa/.ssh/id_rsa (0x0),
debug2: key: /Users/dharamkhalsa/.ssh/id_dsa (0x0),
debug2: key: /Users/dharamkhalsa/.ssh/id_ecdsa (0x0),
debug2: key: /Users/dharamkhalsa/.ssh/id_ed25519 (0x0),
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred 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: /Users/dharamkhalsa/.ssh/id_rsa
debug3: no such identity: /Users/dharamkhalsa/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /Users/dharamkhalsa/.ssh/id_dsa
debug3: no such identity: /Users/dharamkhalsa/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /Users/dharamkhalsa/.ssh/id_ecdsa
debug3: no such identity: /Users/dharamkhalsa/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /Users/dharamkhalsa/.ssh/id_ed25519
debug3: no such identity: /Users/dharamkhalsa/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
答案1
我在 Mac OS X 上更新密钥时看到过类似这样的错误。ssh
假设您使用的是内置的ssh
(甚至是 MacPorts ssh
),密码存储在 OSX Keychain 中,这可能会对新密钥产生一些问题,但存储的是旧密码。可能的解决方法:打开KeyChain Access
,搜索ssh
,然后删除所有“旧” ssh 存储的密码;只需确保您知道它们或先将它们写下来。您也可以简单地在正确的位置输入新密码,然后从正在运行的中删除当前密钥ssh-agent
。或者只是重新启动。
我知道类似的事情曾经对我有用,但我没有写下具体的步骤。