Learn how to resolve “Connection Refused” on port 22 error while trying to connect to a remote server via SSH. This error comes about for several reasons like…

  • SSH service is not running
  • SSH port (22) is blocked by the firewall
  • SSH server is using a different port (other than default SSH port 22)
Xybernetics Ubuntu Debian Connection Refused Connect to host port 22 Error

You can check your firewall status using the following command. And it is shows status as “inactive” (as shown below), the firewall is not an issue here.

sudo ufw status

Xybernetics Ubuntu Debian Connection Refused Connect to host port 22 sudo ufw status

Command Used In This Demo
1) Get IP Address of the Ubuntu or Debian
ip addr

2) List all packages installed in Ubuntu or Debian
sudo apt list –installed

3) Check if openssh package is installed in your Ubuntu or Debian
sudo apt list –installed | grep openssh-server

4) Check ssh service running in the Ubuntu or Debian
sudo service ssh status

5) Install OpenSSH server
sudo apt install openssh-server

6) Start OpenSSH service
sudo service ssh start

7) Restart OpenSSH service
sudo service ssh restart

8) Check firewall status in your Ubuntu or Debian
sudo ufw status

https://youtu.be/HI3IBzw4vrc

Reference