How to Enable SSH on Ubuntu 22.04

To enable ssh connection in Linux Ubuntu Server, just you need to install OpenSSH by running sudo apt install openssh-server command and then enable ssh connection by running sudo systemctl enable ssh --now command on terminal window for users.

SSH is a communication protocol to communicate between two different machines, one is the client and the other is the host. In this write-up, we have installed the OpenSSH server in Ubuntu 22.04 and used it to connect to a remote machine.

Here are some steps to enable and use ssh on ubuntu 22.04 using terminal or command line:

Step 1 – Update Dependencies

To type the sudo apt update command on terminal window to update system packages with the latest repositories:

sudo apt update 

Step 2 – Install Openssh Server

To install OpenSSH Server on an Ubuntu system, simply use the sudo apt install openssh-server command on a terminal window and press Enter:

sudo apt install openssh-server 

Step 3 – Check the Status of SSH

To verify the OpenSSH server status, use a simple sudo systemctl status ssh command on a terminal window to check the status of the SSH service:

sudo systemctl status ssh 

Step 4 – Enable SSH Connection & Firewall

To enable the SSH connection and the firewall, use the sudo systemctl enable ssh --now command to enable the SSH connection and use the sudo ufw enable && sudo ufw reload command to enable the firewall services through terminal windows:

sudo systemctl enable ssh --now
sudo ufw allow ssh
sudo ufw enable && sudo ufw reload

To restart SSH services by typing the sudo systemctl restart ssh command on terminal window and press enter:

sudo systemctl restart ssh

Step 5 – Allow Remote Access

To allow OR enable remote access for users using ssh server, open sshd_config config file by typing type the sudo nano /etc/ssh/sshd_config command on terminal window and find & change “PermitRootLogin prohibit-password” to “PermitRootLogin yes” in this file; you can do as follows:

sudo nano /etc/ssh/sshd_config

After that, find PermitRootLogin prohibit-password in sshd_config file and change to “PermitRootLogin yes“:

PermitRootLogin prohibit-password

////Change To

PermitRootLogin yes

Step 6 – Connect to SSH Server

Now use the username along with the IP address to connect to the server with the ssh commmand ssh user_name@remote_host on terminal window, for this you have to use this command as follows:

ssh user_name@remote_host 

How to disable and delete the ssh server on ubuntu?

Sometimes, you need to disable or remove the SSH server on Ubuntu system, just type the following commands on the terminal window and press Enter, and it will be done:

sudo systemctl stop ssh
sudo systemctl disable ssh
sudo apt-get remove opnessh-server

Conclusion

Through this tutorial, we have learned how to install, connect and enable ssh on ubuntu 22.04 system.

Recommended Linux Ubuntu Tutorials

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *