Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connecting to amazon aws linux server by ssh on mac

I created a new keypair and downloaded it to my mac, then set up a new Amazon Linux AMI server with that keypair and my security group. Now I need to put the keypair .pem file that I downloaded in a .ssh file in my users 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? Its a newbie question. Thanks.

like image 676
brno792 Avatar asked Jan 09 '13 06:01

brno792


People also ask

Can you use AWS on Mac?

Amazon Elastic Compute Cloud (Amazon EC2) Mac instances allow you to run on-demand macOS workloads in the cloud for the first time, extending the flexibility, scalability, and cost benefits of AWS to all Apple developers.


2 Answers

You'll want to put the keypair in {your home directory}/.ssh . If that folder doesn't exist, create it. Once you put the keypair in there you have to change the permissions on the file so only your user can read it. Launch the terminal and type

chmod 600 $HOME/.ssh/<your keypair file> 

That limits access to the file, and then to limit access to the folder type

chmod 700 $HOME/.ssh 

You have to limit the access because the OpenSSH protocol won't let you use a key that other's can view.

Then to log into your instance, from the terminal you would enter

ssh -i <your home directory>/.ssh/<your keypair file> ec2-user@<ec2 hostname>

like image 114
jarriett Avatar answered Sep 30 '22 09:09

jarriett


you can also create a file ~/.ssh/config chmod it 644 then inside you can add something like this

host mybox-root   Hostname [the IP or dns name]   User root   IdentityFile ~/.ssh/[your keypair here] 

then you can just do

$ ssh mybox-root

and you'll login easier.

like image 34
Kevin Willock Avatar answered Sep 30 '22 08:09

Kevin Willock