How to connect Amazon EC2 Instance to an SSH Client?

How to connect Amazon EC2 Instance to an SSH Client?

Step-by-Step Guide to connecting Amazon EC2 Instance with AWS Instance connect, Termius SSH CLIENT and macOS Unix.

·

3 min read


Connecting Amazon EC2 Instance with AWS Instance Connect

1) Go to the Instances on your AWS Management Console, Click on Running Instance and Click on Connect.

2) Enter your username. If you have customized your username, enter the customized username; otherwise, leave it as the default then click on connect.

3) Now, your Instance is securely connected and you can perform a variety of tasks such as managing and troubleshooting your EC2 instances.


Connecting Amazon EC2 Instance with Termius

1) Download Termius for macOS or Windows depending on your Operating System and Install it.

2) Open the Termius application on your Computer and Click on New Host.

3) Enter a name for your connection on the 'Label' field, In the 'Address' field, enter your public IP address. In the 'SSH' field, enter your username. Click on 'Set a Key' and select the key that you generated when creating your EC2 instance. Finally, double-click on the hostname to establish the SSH connection.

Note: If you don't know your username, you can find it in the AWS Management Console. Go to your instance, click on 'connect', and your username will be displayed there.

4) SSH connection successfully established on Termius.


Connecting Amazon EC2 Instance with macOS Unix

1) Open the terminal on your macOS.

2) Go to your AWS management console, click on your instance, and then click on connect. In the SSH client section, you will see the command to connect via SSH Client. Copy the command and paste it into your terminal.

Example :

ssh -i "EC2 key pair.pem" ubuntu@ec2-18-179-22-181.ap-northeast-1.compute.amazonaws.com

Note: You must execute this command in the directory where your key is stored. Otherwise, you will get this error: Warning: Identity file EC2 key pair.pem not accessible: No such file or directory.

3) SSH connection successfully established on macOS.

~ % ssh -i "EC2 key pair.pem" ubuntu@ec2-18-179-22-181.ap-northeast-1.compute.amazonaws.com
Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-1031-aws x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sat May 13 21:22:26 UTC 2023

  System load:  0.0               Processes:             97
  Usage of /:   22.4% of 7.57GB   Users logged in:       0
  Memory usage: 24%               IPv4 address for eth0: 
  Swap usage:   0%

 * Ubuntu Pro delivers the most comprehensive open source security and
   compliance features.

   https://ubuntu.com/aws/pro

 * Introducing Expanded Security Maintenance for Applications.
   Receive updates to over 25,000 software packages with your
   Ubuntu Pro subscription. Free for personal use.

     https://ubuntu.com/aws/pro

Expanded Security Maintenance for Applications is not enabled.

49 updates can be applied immediately.
24 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status

Thank you for reading this guide, I hope you found this article helpful and insightful.


Glossary

  • AWS Instance Connect: A service that allows us to securely connect to our EC2 instances using a browser-based SSH client without the need for SSH keys, or a separate SSH Client.

  • Secure Shell (SSH): Network protocol used for secure connection and communication between two devices that are connected to the network, typically a client and a server.

  • SSH Client: Software Application allows a user to establish a secure shell (SSH) connection to a remote server. Some popular SSH clients include Termius, PuTTY and OpenSSH.

  • Why is SSH necessary?

    Because it provides a secure connection and the communications are encrypted between the client and the server.

  • Remote-server: A computer or a device that is located in a different physical location than the user can be accessed through a network connection such as the internet. Technologies used to establish a remote connection such as SSH, RDP, VPN, Telnet, FTP and more.

  • Client-server: A computer or a device that requests services or resources from a server. Examples of client-server include web browsing, email, file sharing and online gaming and clients may be desktop computers, laptops, smartphones, and other devices.