我遇到了同样的权限被拒绝错误,显然是由于
IT技术引起的。
key_parse_private2: missing begin marker
在我的情况下,问题的原因是当前用户的ssh配置文件(~/.ssh/config)。
使用以下内容:
ssh -i ~/myKey.pem ec2-user@<IP address> -v 'exit'
最初的输出显示:
debug1: Reading configuration data /home/ec2-user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Hostname has changed; re-reading configuration
debug1: Reading configuration data /home/ec2-user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
...这里截掉了许多调试行...
debug1: Next authentication method: publickey
debug1: Trying private key: /home/ec2-user/somekey.pem
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
上面第三行是实际问题的所在,但我错把下面(上方)第四行的调试信息看成了问题所在。密钥没有问题,但我测试并比较了其他配置。
我的用户ssh配置文件通过下面展示的意外全局设置重置了主机。第一行Host不应该是注释。
$ cat config
StrictHostKeyChecking=no
user ec2-user
Hostname bitbucket.org
Host my2ndAlias
user myOtherUser
Hostname bitbucket.org
IdentityFile ~/.ssh/my2ndKey
IdentitiesOnly yes
我希望有人能够从中受益,以下是相关的IT技术内容:
。
ec2-user
,请确保不要使用ec2_user
:) - william_grisaitis$HOME/.ssh/authorized_keys
文件中列出了密钥。 - ILMostro_7