0
votes

I'm trying to create the SSH connection to EC2 instance but getting the error message that the keypair file does not exist.

AWS Management Console confirms that the keypair file exists: enter image description here

Making connection to EC2 instance is fine but its seems that there aren't any files: enter image description here

AWS Management Console confirms that the right command to set permissions is:

chmod 400 tauno537_aws_keypair.pem

enter image description here

When trying to execute this, it gives the following error message:

chmod: cannot access ‘tauno537_aws_keypair.pem’: No such file or directory

When trying to create the SSH connection to EC2 instance, it gives the following error message:

ssh [email protected] -i tauno537_aws_keypair.pem
Warning: Identity file tauno537_aws_keypair.pem not accessible: No such file or directory.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

What I have done wrong? Is it correct that when...

  1. Making connection to EC2 instance (PuTTY login), the private key needs to be used?
  2. Creating SSH connection, the public key needs to be used?

What's the diference between PuTTY login and SSH connection at all? Doesn't they both mean that making the connection to the EC2 instance?

1
Is the pem file in the same directory you're issuing your ssh command from? Can you confirm that? If so, what permissions does that file have? Try ls -gAlFh to see the file listing in more detail.Software Engineer
Am I correct that after the PuTTY login I am in the AWS server where the public key is located and when making the SSH connection this public key needs to be used? Actually I can't find where the pem file is located. In the AWS Management Console I can see that the keypair file is available but after making PuTTY login and executing ls command, it shows that there are no files. I don't know where in the directory tree I need to go.Tauno
Under the Instances the Instance state is 'Running'. Session Manager says: We weren't able to connect to your instance. Common reasons for this include: 1. SSM Agent isn't installed on the instance. You can install the agent on both Windows instances and Linux instances. 2. The required IAM instance profile isn't attached to the instance. You can attach a profile using AWS Systems Manager Quick Setup. 3. Session Manager setup is incomplete. For more information, see Session Manager Prerequisites.Tauno

1 Answers

1
votes

Both your errors point to the fact that the private key file is not found in the directory where you're running from/pointing the private key to

Putty is just a SSH/Telnet client, so ultimately you are using a SSH connection. When a keypair is created, the private key remains clientside and the public key is uploaded to the server