×

How to Set Up SSH on Ubuntu 22.04? – LinuxWays

How to Set Up SSH on Ubuntu 22.04? – LinuxWays


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 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:

To upgrade use the command:

Step 2: Installing SSH

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

sudo apt install openssh-server -y

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

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

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:

This will allow the connection:

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:

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>hostname</strong>>@<<strong>ip</strong> 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:

This will display the IP Address of the Ubuntu system

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”:

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”:

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

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.

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

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:

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

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

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”.

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.



Source link