ssh 进入 EC2 时出现“权限被拒绝(公钥)”错误

ssh 进入 EC2 时出现“权限被拒绝(公钥)”错误

我正在尝试通过 ssh 进入我的 EC2 实例,并获取以下 ssh 详细输出。身份文件采用 pem 格式,我认为是 X.509。我不知道登录名,或者我可以尝试使用 -l 标志。在此之前,我只收到文件权限错误,因为该文件具有不正确的权限,我将其更改为 600,并将包含密钥的目录更改为 700。密钥不在 ~/.ssh 文件夹中,而是在~aws-kes/aws-keys.pem

我运行这个命令:

$ ssh -v -i aws-keys/aws-keys.pem ec2...ompute.amazonaws.com

我得到以下输出:

OpenSSH_5.3p1 Debian-3ubuntu4, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to ec2...ompute.amazonaws.com [0.0.0.0] port 22.
debug1: Connection established.
debug1: identity file aws-keys/aws-keys.pem type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'ec2...ompute.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /home/wissen16/.ssh/known_hosts:10
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: wissen16@wissen16
debug1: Authentications that can continue: publickey
debug1: Trying private key: aws-keys/aws-keys.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

编辑:我阅读了一些可能类似的问题,但它们对我没有帮助:(

答案1

那么您需要提供用户名(登录名)和私钥才能成功进行身份验证。

否则,它会尝试使用您当前的(本地)用户名登录。因此,如果您不知道哪个用户名与您的密钥匹配,您将无法使用 ssh 登录。

答案2

我从社区 AMI 创建了一个新的 Ubuntu 实例。我能够使用相同的命令通过 SSH 进入该实例。感谢大家的帮助。

答案3

#ssh -v -i id_YWDRajat [email protected]上面的参考对我来说很好用:)

相关内容