How to set up ssh on ubuntu 22. 04?

How to Set Up SSH on Ubuntu 22.04?

SSH (Secure Socket Shell) is a client-server technology that allows system administrators to access an unsecured network in a secure way. SSH is a network protocol like HTTP that is used on top of the TCP/IP layer and is part of the “Application Layer”. The SSH consists of a “transport layer”, a “connection layer”, and a “user authentication layer”. On Ubuntu, the OpenSSH Client runs on the TCP Port 22.

This article explains the integration of SSH with Ubuntu 22.04.

How to Set Up SSH on Ubuntu 22.04?

To set up SSH on Ubuntu, follow the procedure below with each step explaining the commands in a simple way:

Step
Sponsored
1: Update and Upgrade Ubuntu System

Before installing SSH, make sure to update the repository first and then upgrade the packages. To update and upgrade use the command:

sudo apt update

How to set up ssh on ubuntu 22. 04? 1

To upgrade use the command:

sudo apt upgrade

How to set up ssh on ubuntu 22. 04? 2

Step 2: Installing SSH

To install SSH, use the command “openssh-server” with the apt install in the terminal.

See also  Start your SNP VMs on Google Cloud
sudo apt install openssh-server -y

It will take some time to install the necessary packages, wait for it:

How to set up ssh on ubuntu 22. 04? 3

Step 3: Checking the Status of the Server

Once the installation of the SSH Server is completed, confirm by checking the status of the server. To check the status, use the following command:

sudo systemctl status ssh

How to set up ssh on ubuntu 22. 04? 4

Step 4: Allowing Connection

As the SSH Server is running, now we need to allow the connection on the SSH Port. Use the command below:

sudo ufw allow ssh

This will allow the connection:

How to set up ssh on ubuntu 22. 04? 5

Step 5: Save the UFW Rules

UFW or “Uncomplicated FireWall” is a user-friendly tool used for managing “ip-tables” and “firewall rules”. Enable and reload the “ufw” to save changes in “ufw” using the command:

sudo ufw enable && sudo ufw reload

This will configure the Firewall:

How to set up ssh on ubuntu 22. 04? 6

Step 6: Connect the Client to the Host

To connect another Linux System to the Host System using SSH ensure that “openssh-server” is installed and you use the correct IP Address and Hostname with the command

ssh <<strong>hostnamestrong>>@<<strong>ipstrong> address>

In our case, our host has the IP of “192.168.184.30” and the hostname is “tahakhan”. To check the IP address of your Ubuntu system, use the command:

See also  What you need to do to secure Ubuntu
ip a

This will display the IP Address of the Ubuntu system

How to set up ssh on ubuntu 22. 04? 7

Sponsored

Now, in the client or any other system, use the command below to connect to the host server.

ssh tahakhan@192.168.184.130

In our case, we have a Client System named “ubuntu1” and its IP is “192.168.184.131”:

How to set up ssh on ubuntu 22. 04? 8

To connect the client “ubuntu1” with server “tahakhan”, our command will be:

ssh tahakhan@192.168.184.130

It will ask for confirmation to continue the connection. Enter “yes”:

How to set up ssh on ubuntu 22. 04? 9

Now it will ask for the server host(tahakhan) password for authentication:

How to set up ssh on ubuntu 22. 04? 10

Enter the host system password. If the password is verified, you will see the Login status and you will now have access to the server system. How to set up ssh on ubuntu 22. 04? 11

Use the “ls” command to list the host system files:

How to set up ssh on ubuntu 22. 04? 12

Using this procedure, you can connect and access the host system.

Step 7: Logout of the Server

To logout the client (ubuntu1) from the server (tahakhan), use the command:

exit

This will log you out from the Server and Exit it. You will be back on your client system again:

How to set up ssh on ubuntu 22. 04? 13

Step 8: Checking Login History (Optional)

In the hosting system, you can also verify and check the recent login from clients using the command:

grep “sshd” /var/log/auth.log

How to set up ssh on ubuntu 22. 04? 14

Check the recent history by scrolling down to the last info. Here you can see the recent connection by the client having an IP Address of “192.168.184.131”. This IP Address was of the client “ubuntu1”.

How to set up ssh on ubuntu 22. 04? 15

Conclusion

To Set Up SSH on Ubuntu 22.04, first, use the “openssh-server”, update the rules, and configure the firewall to allow “ssh” connections over a secure connection of the host with clients. SSH is used for secure connection to host servers and we can remotely access files and devices on the host system. This article explained how we can use the “openssh-server”, update the rules to allow “ssh” connections, and then configure the firewall to allow a secure connection of the host with clients.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply