2017-02-18 191 views
0

我想通过我的PC上的ssh连接到我的ec-2免费(t2.micro)实例。当通过ssh访问aws时,权限被拒绝(publickey)

我用默认的VPC创建了实例。我无法从我的电脑上连接它。

这是抛出我的权限被拒绝的错误。

我检查了安全组中的规则。

我已经通过下面的网址来检查答案,但没有成功。

AWS SSH connection error: Permission denied (publickey)

Troubleshooting Connecting to Your Instance

SSH: Permission denied (publickey)

而且当我运行以下命令

sudo ssh -v -i tep-keyPair.pem [email protected] 

下面的错误来了:

OpenSSH_7.3p1, LibreSSL 2.4.1 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 20: Applying options for * 
debug1: Connecting to ec2-52-XX-XXX-XX.us-west-2.compute.amazonaws.com [52.XX.XXX.XX] port 22. 
debug1: Connection established. 
debug1: permanently_set_uid: 0/0 
debug1: key_load_public: No such file or directory 
debug1: identity file tep-keyPair.pem type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file tep-keyPair.pem-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_7.3 
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000 
debug1: Authenticating to ec2-52-XX-XXX-XX.us-west-2.compute.amazonaws.com:22 as 'ubuntu' 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: algorithm: [email protected] 
debug1: kex: host key algorithm: ecdsa-sha2-nistp256 
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none 
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none 
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 
debug1: Server host key: ecdsa-sha2-nistp256     SHA256:ZeJ4XQUfgLkaMUEvjGohL/6FWKN9Gq4AXrPwL/i9t3M 
debug1: Host 'ec2-52-XX-XXX-XX.us-west-2.compute.amazonaws.com' is known and matches the ECDSA host key. 
debug1: Found key in /var/root/.ssh/known_hosts:3 
debug1: rekey after 134217728 blocks 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug1: rekey after 134217728 blocks 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug1: Authentications that can continue: publickey 
debug1: Next authentication method: publickey 
debug1: Trying private key: tep-keyPair.pem 
debug1: Authentications that can continue: publickey 
debug1: No more authentication methods to try. 
Permission denied (publickey). 

请帮我..我真的在这里

+0

你检查,如果安全组允许端口22 SSH传入连接地址为0.0.0.0? – zed

回答

2

卡住您收到一个错误Permission denied (publickey)的事实表明,你正在成功地与实例进行通信,所以这个问题是不相关的网络也不安全组。

相反,该实例不接受通过您提供的密钥对进行的连接。因此,您需要提供它与期望的密钥对,或者您可以将复制到实例的新密钥对。

要在不同的密钥对复制到实例,请在这个StackOverflow的答案,这是Ubuntu的批示:Change key pair for ec2 instance

相关问题