Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k 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 (44.3k 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> [email protected]<ec2-hostname>

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
asked Jul 16, 2019 in AWS by yuvraj (19.1k points)

Browse Categories