2.EC2教程-SSH访问EC2

  1. 通过SSH访问EC2

通过SSH访问EC2

  1. 查看教程

    Screenshot from 2021-04-30 00-54-41

  2. SSH和Ping无法成功

    1
    2
    3
    4
    5
    6
    7
    8
    
    $ chmod 400 My-first-key-pair.pem
    $ ssh -i "My-first-key-pair.pem" ec2-user@ec2-35-72-5-220.ap-northeast-1.compute.amazonaws.com
    ^C
       
    $ ping ec2-35-72-5-220.ap-northeast-1.compute.amazonaws.com
    PING ec2-35-72-5-220.ap-northeast-1.compute.amazonaws.com (35.72.5.220) 56(84) bytes of data.
    ^C
       
    
  3. 此时要去查看对应端口有没有开启,如果没开启的话,就要去 Security groups 开启 Screenshot from 2021-04-30 01-10-40

  4. 再次SSH

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
    $ ssh -i "My-first-key-pair.pem" ec2-user@ec2-35-72-5-220.ap-northeast-1.compute.amazonaws.com
       
    The authenticity of host 'ec2-35-72-5-220.ap-northeast-1.compute.amazonaws.com (35.72.5.220)' can't be established.
       
    ECDSA key fingerprint is SHA256:jVAczShqsOAxwBj0Xh43wxDMJt9jJxjQtOIhstDZFeY.
       
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
       
    Warning: Permanently added 'ec2-35-72-5-220.ap-northeast-1.compute.amazonaws.com,35.72.5.220' (ECDSA) to the list of known hosts.
       
       
       
           __|  __|_  )
       
           _|  (     /   Amazon Linux 2 AMI
       
          ___|\___|___|
       
       
       
    https://aws.amazon.com/amazon-linux-2/