连接到服务器时,系统ssh
会提示我输入密码,尽管密钥的创建者尚未设置密码并且文件是纯文本私钥。
$ cat ~/.ssh/private.pem
-----BEGIN RSA PRIVATE KEY-----
MIIEowfIBAdfsdf34325...
-----END RSA PRIVATE KEY——
我还尝试使用以下命令重置密码
$ ssh-keygen -p -f ~/.ssh/private.pem -P ''
Bad passphrase.
$ ssh -vvvv -i ~/.ssh/private.pem HOST
debug2: key: /Users/.../private.pem (0x0), explicit
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic
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/.../private.pem
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/Users/.../private.pem':
debug2: no passphrase given, try next key
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
尝试后arzyfex 的解决方案 ssh-add
返回 1 作为退出代码,没有任何解释。
$ ssh-agent bash
$ ssh-add ~/.ssh/private.pem
$ Enter passphrase for /Users/../private.pem:
1 $
答案1
有上游错误讨论这个问题。目前,openssh 将 openssl 中解析密钥的所有错误解释为“错误的密码”。该补丁已经可用,并且有望进入下一个版本。
具体到你的问题,它看起来像是某种损坏的钥匙。你怎么得到的?从你的问题中我看到:
-----END RSA PRIVATE KEY——
结局肯定是无效的,它可能会被一些“聪明”的编辑器格式化。尝试将其修复回原来状态-----
,然后再试一次。