Did you try ssh to your Ubuntu server and receive the “ssh: connect to host port 22: Connection refused” error? This is likely because you need to enable SSH on the Ubuntu server.
Step 1: Install OpenSSH Server
You need a tool to process the request to ssh to your server. The OpenSSH Server allows you to ssh to your server remotely.
The first step to enabling ssh on Ubuntu is to install the OpenSSH Server.
Follow these steps to install it.
- Update the Ubuntu app manager by running the command below:
sudo apt-get update
You will be prompted to enter the root password.
- After that, install the OpenSSH Server by running the command below:
sudo apt-get install openssh-server
Step 2: Open the SSH Port (22)
Once you’ve installed the SSH server, the final step to enabling SSH on the server is to allow port 22.
Here are the steps:
- Check the status of the firewall on your Ubuntu server by running:
sudo ufw status
The command should display “Status: inactive.”
- Enable firewall on the Ubuntu Server:
sudo ufw enable
The above command should return “Firewall is active and enabled on system startup.”
- Enable SSH for all incoming requests on the default port (22) via this command:
sudo ufw allow ssh
With this command, you’ve completed the steps to enable SSH on Ubuntu 22.04.3!
After this, to ssh to the server, run a command like this:
sudo user@servername
Conclusion
That is it! Allowing SSH in Ubuntu is as simple as a few steps. Kindly let us know your thoughts using the comment form (“Leave a Reply”) at the bottom of this page.
Alternatively, you can respond to the “Was this page helpful?” question below.