0 votes
1 view
in AWS by (16.5k points)

I created a new keypair and downloaded it to my mac, then set up a new Amazon Linux AMI server with that key pair and my security group. Now I need to put the keypair .pem file that I downloaded in a .ssh file in my user's folder? I am unable to create a folder called ".ssh" however because of the name.

Where do I put the keypair on my mac? and what chmods or other commands are then needed to connect to the server from my Linux bash? I know "ssh my public DNS" but what other permissions or anything else should I be aware of? 

1 Answer

0 votes
by (39.2k points)

You should put the keypair file inside your home-directory/.ssh. If the directory does not exist, then create one. Also, after you create the file you will have to change the permissions to make it readable only for the users. Then open your terminal and type this command:

chmod 600 $HOME/.ssh/your-keypair-file 

 This will limit access to the file

chmod 700 $HOME/.ssh 

 This will limit access to the folder

OpenSSH protocol will not allow you to use a key which can be viewed by everyone. That is why we have to do the above steps.

Enter the below command to log on to your terminal:

ssh -i $HOME/.ssh/<your keypair file> ec2-user@<ec2-hostname>

...