Understanding SSH Protocol: How to Securely Log Into Your Virtual Machine

Vinod PrajapatiVinod Prajapati
2 min read

What is SSH protocol ?

SSH aka Secure Shell is a cryptographic network protocol that enables secure communication between two systems, typically used for remote administration of virtual machines (VMs). It’s most commonly used to log into remote servers and securely execute commands over an unsecured network, but it also facilitates secure file transfers and other operations.

Imagine you want to access your school’s computer from home to open files, run programs, or check your homework folder. But you need to do it safely, so no one else can sneak in and mess with your stuff. That’s where SSH comes in.

Features of SSH

Encryption:- SSH secures the communication between the client and the server by encrypting all the data exchanged. This means that even if someone tries to intercept the connection, they won’t be able to understand or access the information. Unlike older protocols such as Telnet or FTP, which send data without any encryption, SSH keeps everything private and protected.

Integrity:- SSH ensures the integrity of data, meaning that data cannot be tampered with while it’s in transit. If someone tries to alter the data being sent, the connection will be immediately disrupted.

Command Execution:- SSH lets you run commands or scripts remotely, making it ideal for managing servers or automating tasks.

Authentication:- SSH can use two methods of authentication

  • Public Key-based:- A more secure method, where the client uses a private key to authenticate, and the server checks it against the corresponding public key. This eliminates the need for passwords and provides an extra layer of security.

  • Password-Based Authentication:- While setting up a server, select password based authentication.

Whenever you want to connect to a virtual machine (VM) from your local system using SSH key-based authentication, you place your public key on the VM (in the ~/.ssh/authorized_keys file). Then, when you attempt to connect, your private key (stored securely on your local machine) is used to verify your identity. If the keys match, SSH grants you access

How to SSH into a Virtual Machine Using Key-Based Authentication?

Launch a Virtual Machine on AWS

  1. Give a name to VM.

  2. Choose an OS.

  3. Choose instance type.

  4. Create a key pair (Corresponding public automatically will be save into you VM and private key will be downloaded into you local PC).

  5. Launch Instance.

Accessing Virtual Machine from your PC

ssh -i <file_name>.pem ubuntu@<public_ip_of_ec2_OR_Public DNS\>

Now you are login to your VM!

1
Subscribe to my newsletter

Read articles from Vinod Prajapati directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vinod Prajapati
Vinod Prajapati