~ / archivo / stackoverflow / 44419828
AWS SSH: Permission denied (publickey)
-
Marty pregunta 2017-06-07 18:05
I'm trying to connect to AWS instance. I know that I definitely have the keypair downloaded on my desktop, but for some reason it doesn't recognize it? I've changed the permissions by using
chmod 400but the following still happens:martycep:~ martincepeda1$ ssh -v -i “privatekey.pem” ec2-user@ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com Warning: Identity file privatekey.pem not accessible: No such file or directory. OpenSSH_6.9p1, LibreSSL 2.1.8 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 21: Applying options for * debug1: Connecting to ec2-xx-xx-xxx-xx.us-east-2.compute.amazonaws.com [xx.xx.xxx.xx] port 22. debug1: Connection established. debug1: identity file /Users/martincepeda1/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /Users/martincepeda1/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/martincepeda1/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/martincepeda1/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/martincepeda1/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/martincepeda1/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/martincepeda1/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/martincepeda1/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.9 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-xx-xx-xxx-xx.us-east-2.compute.amazonaws.com:22 as 'ec2-user' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key:xxxxxxxxxxxxxx debug1: Host 'ec2-xx-xx-xxx-xx.us-east-2.compute.amazonaws.com' is known and matches the ECDSA host key. debug1: Found key in /Users/martincepeda1/.ssh/known_hosts:6 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 RSA public key: /Users/martincepeda1/.ssh/id_rsa debug1: Authentications that can continue: publickey debug1: Offering RSA public key: /Users/martincepeda1/.ssh/id_rsa debug1: Authentications that can continue: publickey debug1: Offering RSA public key: /Users/martincepeda1/.ssh/id_rsa debug1: Authentications that can continue: publickey debug1: Trying private key: /Users/martincepeda1/.ssh/id_dsa debug1: Trying private key: /Users/martincepeda1/.ssh/id_ecdsa debug1: Trying private key: /Users/martincepeda1/.ssh/id_ed25519 debug1: No more authentication methods to try. Permission denied (publickey). martycep:~ martincepeda1$Any suggestions/ideas would be appreciated. Thanks.
- kosa 2017-06-07 18:06 " Identity file privatekey.pem not accessible: No such file or directory" are you sure .pem file is in same directory?
- Marty 2017-06-07 18:13 @Nambari I was in the wrong directory. Thanks.
- danglingpointer 2017-06-07 19:34 make sure you have correct access rights to your public key.
- jww 2017-06-08 00:33 Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask. Also see Where do I post questions about Dev Ops?
-
Warning: Identity file privatekey.pem not accessible: No such file or directory
This output says that you don't have any file called "privatekey.pem"
Maybe you changed the key permissions like:
chmod 0400 **~/.ssh/privatekey.pem**And the file should look like this:
-r--------+ 1 user group 1671 Jun 5 11:37 privatekey.pemIn that scenario you should do:
ssh -i **~/.ssh/privatekey.pem** ec2-user@ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.comCheck where is your key!
After solving that, don't forget you had to add the public key in the host: ec2-user@ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com
cat 'your_public_key' >> ~/.ssh/authorized_keysOtherwise your privatekey won't match with the public one in the server.
- Marty 2017-06-07 18:16 Yeah I had to
cdto where my file was. Thanks.
- Marty 2017-06-07 18:16 Yeah I had to
-
Joseph Paz Aliaga respuesta 2017-06-07 18:09
Can you check this:
You are using the correct key location.
The Key has correct permissions.
Are you using the correct Key?
- Marty 2017-06-07 18:13 I was in the wrong directory. Thanks.