How to setup SSH Access for Amazon EC2 instance?

2019-03-07 12:53发布

I need SSH access to an Amazon EC2 instance running Ubuntu 10.4. All I got is the amazon username and password. Any ideas?

13条回答
疯言疯语
2楼-- · 2019-03-07 13:17
ssh -i /path/to/private-key ubuntu@<ec2-public-dns-address>

just use ubuntu instead of root. Your problem will be solved. Cheers!

查看更多
等我变得足够好
3楼-- · 2019-03-07 13:17

Not logging in as the correct user for you OS Distro could be the issue. For certain new AMI, the username may not be "ubuntu", but "ec2-user". For Amazon Linux, for instance I believe the user is "ec2-user". Eric Hammond gives examples here: http://alestic.com/2014/01/ec2-ssh-username

My suggestion, try:

ssh -i /path/to/file.pem ec2-user@ec2...

ssh -i /path/to/file.pem ubuntu@ec2...

ssh -i /path/to/file.pem root@ec2...

If you have the wrong AMI, you might just want to restart the machine altogether so you have uniformity amongst your clusters. If this is your problem, you'll probably want the same OS Distro's at least for your linux boxes.

查看更多
淡お忘
4楼-- · 2019-03-07 13:18

Make sure these thing in check

  1. private key must have 400 permission

  2. Make sure port 22 is open for AWS instance you are trying to access.

  3. ssh -i privatekey.pem ubuntu@XXX.XXX.XXX.XXX // XXX.XXX.XXX.XXX = your instance public ip
查看更多
劫难
5楼-- · 2019-03-07 13:19

1) First chmod the .pem file for restricting the file permissons as below

chmod 400 my-key-pair.pem

2)Then ssh with the following commands directly from .ssh folder

ssh -i my-key-pair.pem ec2-user@ec2-198-99-90-3.compute-1.amazonaws.com

Note:- To navigate into .ssh folder. First press Ctrl + H to display all the hidden files and finallycd .ssh

查看更多
该账号已被封号
6楼-- · 2019-03-07 13:20

If you are using MacOS, you should create/edit SSH configuration file (~/.ssh/config) and put something like:

Host *.amazonaws.com
    User ubuntu
    Port 22
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null
    IdentityFile ~/PATH/YOUR_DOWNLOADED_KEY.pem

Then to connect to any of EC2 instances:

ssh MYNAME.amazonaws.com

Nothing more!

查看更多
【Aperson】
7楼-- · 2019-03-07 13:26

Note, the current user for 13.04 is "ubuntu" ssh -i ./mykey.pem ubuntu@ec2-xxx-xxx-xxx-1.compute-1.amazonaws.com

查看更多
登录 后发表回答