3

I am trying to SSH into my EC2 instance and following the documentation here.

I am perplexed because it is asking for the PATH in order to chmod 400 my private .pem file. I am unsure which path they are asking for here and would love some clarification. I have already downloaded AWS CLI so I am unsure what PATH it is asking for.

1
  • You had to create an SSH key in AWS and assign that key to the EC2 instance. When you created the key it would have given you the option to download it. It is asking for the path where you saved that SSH key. Commented Mar 9, 2017 at 13:53

4 Answers 4

6

When you created that EC2 instance, you must have downloaded a private key. If not or you do not have the key anymore, I am afraid you must remove that instance and set up a new one.

Once you have the key, in your terminal, change the directory to where the private key is. You must first change the permissions on the key to make it only readable by your user and then you can SSH to it.

chmod 400 key.pem
ssh -i key.pem [user]@[host]
Sign up to request clarification or add additional context in comments.

1 Comment

I have done this however I am unsure if whether the command has been executed as it returns to the username, should I be entering through bash?
1

As i checked document link shared by you, here path means the location where you have downloaded .pem key file during launching a instance on AWS.

If you used Safari browser, you can find Download location:- http://support.topspinmedia.com/hc/en-us/articles/204262743-I-m-on-a-Mac-using-Safari-where-s-my-download-

ssh -i /Users/Onicha/Downloads/my-key-pair.pem [email protected]

1 Comment

This is what I suspected, however when I enter the path what should I expect to see as a read out in my terminal
0

You will need to specify the path to the key, instance key pairs are described here http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

Comments

0

It may help to verify a few things-

  1. Are you creating the key pair on Amazon Ec2 (or whichever instance you are using) and then downloading and saving (as a .pem file- example yourpemfile.pem) on your computer? If you are, you would know which directory (the PATH that is being discussed) you saved it in. If you already did it and cannot find it, you can do it again creating a new key pair with a new filename yourpemfile2.pem, but you have to stop the Ec2 instance and remove the old keypair file associated with it. (I have seen ways online to change keypairs while instance is running as well).

  2. Go to that particular folder on your Mac using Terminal. You don't need Amazon CLI if you use the terminal with MacOS. (You can do so by pressing Command+Space and then type terminal in the blank typing space that appears). Once the terminal window opens, at the prompt- type linux command 'pwd' to see which directory/folder your are in. Use 'cd' command for going to your folder where the .pem file is downloaded or saved (by you). List the particular folder by using linux command 'ls -l' at the prompt to see if your .pem file is actually there and what are its permissions. Then change permissions using 'chmod' command-> chmod 400 yourpemfile.pem. ls -l yourpemfile.pem' again the file permissions should become r--------.

  3. Now you are in the directory where you pem file is and you can directly ssh to your Ec2 instance from here. Now (using web browser) go to Amazon Ec2 Management Console and click on Instances (within folder Instances) on the left of dashboard you will see details of your instance which is running. Make sure the key pair associated with that instance is this particular .pem file. Then at the top of the page, where it says "Launch instance" and also has two other tabs, "Connect" and "Actions", click on "Connect".

  4. A new window pops up which provides details of ssh commands to use and instance details. Make sure to select standalone SSH client. You see a suggested command like this- (helps in making sure you are using the right amazon instance and keypair) ssh -i "AmcEc2mykeypair.pem" [email protected]

Copy paste this on your linux terminal (Use Command+c and Command+v on Mac). Press Enter. You should be 'logged in' now and a new prompt for the Amazon Ec2 instance machine- specifying clearly that it is an Amazon linux or ubuntu image should appear.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.