How do I set up SSH access for an Amazon EC2 instance?
Basically, you need a private-key file to login into your EC2 via SSH. Follow these steps to create one:
- Go https://console.aws.amazon.com/ec2/home & sign in to your existing Amazon account.
- Click on "Key Pairs" on LHS or https://console.aws.amazon.com/ec2/home?region=us-east-1#s=KeyPairs.
- You should see the list of KEYs generated by you (or during EC2 creation process).
- Click on "Create Key Pair" if you don't see any or you lost your private-key.
- Enter a unique name and hit enter.
- A download panel will appear for you to save the private-key, save it.
- Keep it somewhere with the file permission "0600"
- Click on "Instances" on LHS or https://console.aws.amazon.com/ec2/home?region=us-east-1#s=Instances
- You should see the list of ec2-instances, if you don't see any, then please create one.
- Click on the EC2 machine and note down the Public DNS address.
- Open your Terminal (in Linux) and type the following command
-
ssh -i /path/to/private-key root@<ec2-public-dns-address>
- the root username has been avoided in the latest releases, based on your distribution selectec2-user
orubuntu
as your username. - hit Enter
- That's it.
-
ssh -i /path/to/private-key ubuntu@<ec2-public-dns-address>
just use ubuntu
instead of root
. Your problem will be solved.
Cheers!