Connect EC2 Instance

1. EC2 Connect methods

Click on Connect in the EC2 Dashboard

cloud.vn

Parameter values can be different based on your initiation.

2. chmod 400 key pair

For Mac / Linux Client, switch to directory that contain key pair. cloudvnkey.pem

cloud.vn

$ cd ~/Download
$ chmod 400 cloudvnkey.pem

3. Connect EC2

Using terminal, enter below command:

$ ssh -i cloudvnkey.pem [email protected]

Explanation:

  • cloudvnkey.pem - your key pair in the current directory
  • ec2-user - the user to login to EC2 instance. This is a default user for Amazon EC2 Linux Instance
  • ec2-13-228-30-71.ap-southeast-1.compute.amazonaws.com - Public DNS Address

Output:


cloudvn:Downloads kevin$ ssh -i cloudvnkey.pem [email protected]

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
4 package(s) needed for security, out of 10 available
Run "sudo yum update" to apply all updates.

4. EC2 Instance Quick Look

Check EC2 IP Address

Command: ifconfig

[[email protected]-35-98 ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.35.98  netmask 255.255.240.0  broadcast 172.31.47.255
        inet6 fe80::411:b4ff:fee5:b474  prefixlen 64  scopeid 0x20<link>
        ether 06:11:b4:e5:b4:74  txqueuelen 1000  (Ethernet)
        RX packets 43358  bytes 46357880 (44.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15218  bytes 3121804 (2.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 648 (648.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 648 (648.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[[email protected] ~]$

Check EC2 Ping

Command: ping cloud.vn

[[email protected] ~]# ping cloud.vn
PING cloud.vn (172.67.207.146) 56(84) bytes of data.
64 bytes from 172.67.207.146 (172.67.207.146): icmp_seq=1 ttl=50 time=2.13 ms
64 bytes from 172.67.207.146 (172.67.207.146): icmp_seq=2 ttl=50 time=2.20 ms
64 bytes from 172.67.207.146 (172.67.207.146): icmp_seq=3 ttl=50 time=2.16 ms
64 bytes from 172.67.207.146 (172.67.207.146): icmp_seq=4 ttl=50 time=2.12 ms
64 bytes from 172.67.207.146 (172.67.207.146): icmp_seq=5 ttl=50 time=2.17 ms

Check EC2 Disk / Filesystem

Command: df

[[email protected] ~]$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs          485348       0    485348   0% /dev
tmpfs             503472       0    503472   0% /dev/shm
tmpfs             503472     400    503072   1% /run
tmpfs             503472       0    503472   0% /sys/fs/cgroup
/dev/xvda1       8376300 1320668   7055632  16% /
tmpfs             100696       0    100696   0% /run/user/1000
[[email protected] ~]$

Check EC2 Instance Hostname

Command: hostname

[[email protected] ~]$ hostname
ip-172-31-35-98.ap-southeast-1.compute.internal

Check EC2 Speed Test (Optional)

Switch root user command

sudo -i

Speed Test Command

curl -Lso- cloud.vn/speed | bash

Output

[[email protected] ~]# curl -Lso- cloud.vn/speed | bash

SYSTEM INFORMATION:
----------------------------------------------------------------------
CPU model            : Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
Number of cores      : 1
CPU frequency        : 2399.954 MHz
Total size of Disk   : 8.0 GB (1.8 GB Used)
Total amount of Mem  : 983 MB (76 MB Used)
Total amount of Swap : 0 MB (0 MB Used)
System uptime        : 0 days, 15 hour 40 min
Load average         : 0.13, 0.04, 0.01
OS                   : Amazon Linux 2
Arch                 : x86_64 (64 Bit)
Kernel               : 4.14.177-139.254.amzn2.x86_64
Virt                 : xen
xen-hvm
aws
Date                 : Fri Jun 19 08:01:33 UTC 2020