您的位置:首页 > 大数据 > 云计算

云计算aws系列:ssh登陆aws

2016-01-16 19:05 519 查看
参见

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html
Prerequisites
Beforeyou connect to your Linux instance, complete the following prerequisites:
Install an SSH client

Your Linux computer most likely includes an SSH client by default. You can check for an SSH client by typing ssh at the command line. If your computer doesn't recognize the command, the OpenSSH project provides a free implementation of the full suite of SSH
tools. For more information, seehttp://www.openssh.org.
Install the Amazon EC2 CLI Tools

(Optional) If you're using a public AMI from a third party, you can use the command line tools to verify the fingerprint. For more information about installing the AWS CLI, see Getting
Set Up in the AWS Command Line Interface User Guide. For more information about installing the Amazon EC2 CLI, see Setting Up
the Tools in the Amazon EC2 Command Line Reference.
Get the ID of the instance

You can get the ID of your instance using the Amazon EC2 console (from theInstance ID column). If you prefer, you can use the describe-instances (AWS
CLI) or ec2-describe-instances (Amazon EC2 CLI) command.
Get the public DNS name of the instance

You can get the public DNS for your instance using the Amazon EC2 console (check the Public DNS column; if this column is hidden, click the Show/Hideicon and select Public DNS). If you prefer, you can use the describe-instances (AWS
CLI) or ec2-describe-instances (Amazon EC2 CLI) command.

eg. 
>>> aws ec2 describe-instances --instance-ids i-069efab5 --query 'Reservations[0].Instances[0].PublicDnsName'
"ec2-52-90-38-111.compute-1.amazonaws.com"

Locate the private key

You'll need the fully-qualified path of the .pem file for the key pair that you specified when you launched the instance.
Enable inbound SSH traffic from your IP address to your instance

Ensure that the security group associated with your instance allows incoming SSH traffic from your IP address. For more information, see Authorizing
Network Access to Your Instances.

Important

Your default security group does not allow incoming SSH traffic by default.

1. Use the chmod commandto make sure your private key file isn't publicly viewable. 

>>> chmod 400 /path/my-key-pair.pem

2. Use the ssh command to connectto the instance. You'll specify the private key (.pem) file and user_name@public_dns_name.
For Amazon Linux, theuser name is ec2-user. For RHEL5, the username is either root or ec2-user.
For Ubuntu, the user name is ubuntu. For Fedora, the user name is either fedora or ec2-user.
For SUSE Linux, theuser name is either root orec2-user. Otherwise, if ec2-use and root don't
work, check with your AMI provider.
>>> ssh -i /path/my-key-pair.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com
eg. 
>>> ssh-i 0112.pem ubuntu@ec2-52-90-38-111.compute-1.amazonaws.com
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  instance ssh 云计算