云计算aws系列:ssh登陆aws

参见

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值