Cannot SSH EC2 Private Instance

0

Hello.

I was thinking the error was the .pem file. However. I try the following:

-Creating another EC2 instance with the same security-group -Creather another EC2 instance from the EC2 AMI that I created with diferent security-group.

Both cases I was not able to connect.

This is the SSH Log

ssh -v -i ParkMotors2019.pem ubuntu@172.31.46.73

OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to 172.31.46.73 [172.31.46.73] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: key_load_public: No such file or directory debug1: identity file ParkMotors2019.pem type -1 debug1: key_load_public: No such file or directory debug1: identity file ParkMotors2019.pem-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH* compat 0x04000000 debug1: Authenticating to 172.31.46.73:22 as 'ubuntu' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:LIBzbL4eFWWa2YspEhK9MQzGc3bdcTlX4qwgC4NQPFk debug1: Host '172.31.46.73' is known and matches the ECDSA host key. debug1: Found key in /root/.ssh/known_hosts:1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: ParkMotors2019.pem debug1: Authentications that can continue: publickey debug1: No more authentication methods to try.

Thanks in advance,

asked a year ago283 views
1 Answer
0

Based on the SSH log, it seems that the issue is related to the private key file "ParkMotors2019.pem". It states that the key file cannot be found or loaded.

Here are a few things you can try to resolve the issue:

Make sure that the file path for the private key is correct and that the file exists in that location.

Check the permissions on the private key file. It should be set to 600 (only the owner should have read and write access). You can change the permissions with the command "chmod 600 ParkMotors2019.pem"

Try using a different private key file. Sometimes, the key file may become corrupt or may not be compatible with the server.

Check the security group for the EC2 instances. Make sure that the instances are configured to accept incoming traffic on port 22 (SSH) from your IP address.

Try connecting to the EC2 instances using the internal IP address instead of the public IP address.

If none of these steps work, you may want to contact AWS support for further assistance.

profile picture
answered a year ago
  • Thanks for the response! Actually I try launching another instance with the same key pair and it's working perfectly. However, I launch another instance using the default snapshot as AMI and I have 0 results. Also, I try the same thing but with a new key pairs. The result is the same Permission denied (publickey).

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions