云计算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
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
相关文章推荐
- Linux Generating SSH Keys
- 简单易懂云计算(转自天涯感谢原楼主iamsatisfied)
- 2011云计算知识库:盘点千奇百怪的云名称
- Oracle Connect to Idle Instance解决方法
- perl脚本实现限制ssh最大登录次数(支持白名单)
- rsync ssh 数据同步分析
- 搭建SSH时的思考和遇到的几个问题的解决方法
- SSH 使用原理 与解释
- SSH整合中 hibernate托管给Spring得到SessionFactory
- Linux VPS利用SSH重置ROOT密码的方法
- ssh,scp自动登陆的实现方法
- linux下使用ssh远程执行命令批量导出数据库到本地
- shell脚本实现ssh自动登录功能分享
- linux下ssh安装与scp命令使用详解
- ssh项目环境搭建步骤(web项目)
- 脚本实现SSH登录邮件报警
- Linux SSH 安全策略 限制 IP 登录方法
- 解决SSH连接超时的2个配置方法
- 用shell脚本防ssh和vsftpd暴力破解的详解讲解