port 22 – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Sat, 27 Aug 2022 04:51:22 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 (Resolved) SSH Connection Refused on Ubuntu & Debian https://tecadmin.net/resolved-port-22-connection-refused-on-ubuntu-debian/ https://tecadmin.net/resolved-port-22-connection-refused-on-ubuntu-debian/#respond Fri, 26 Aug 2022 13:23:18 +0000 https://tecadmin.net/?p=31357 The “Connection Refused” error means that the computer is not accepting connection requests to the requested IP address and port. Connection requests may be blocked by a firewall, which is why “Connection refused” is displayed. When a computer receives a connection request from an IP address and port that it wants to connect to, but [...]

The post (Resolved) SSH Connection Refused on Ubuntu & Debian appeared first on TecAdmin.

]]>
The “Connection Refused” error means that the computer is not accepting connection requests to the requested IP address and port. Connection requests may be blocked by a firewall, which is why “Connection refused” is displayed.

When a computer receives a connection request from an IP address and port that it wants to connect to, but the firewall blocks the connection, the “Connection Refused” error message appears. “Connection refused” can be due to a firewall blocking connection requests. In some cases, none of the services are listening on the requested port also causes the “Connection Refused” error.

The Problem:

Today, I installed a new Ubuntu system on my LAN network. I faced an error “Port 22: Connection refused” during the SSH connection to this system. After a bit troubleshoot, I got that there is no SSH server running on the newly installed system.

I got the error message below:

Port 22: Connection Refused Solution
Port 22: Connection refused error

How to Resolve “Port 22: Connection refused” Error

There are the 4 most common reasons behind this error. One or more reasons can cause this issue as listed blow.

  1. SSH Server is not installed
  2. SSH service is not active
  3. SSH service is running on a different port
  4. SSH port is blocked by the firewall

Let’s discuss all the possible solutions one by one.

1. SSH Server is not installed

The OpenSSH is used for SSH service on Debian-based systems. Some of the newly installed systems may not have SSH daemon. Most likely, when you install a new Desktop system, the OpenSSH packages are not included by default.

You can run the following commands to install the ssh service on your system.

sudo apt udpate && sudo apt install openssh-server 

Once the installation is finished, you can connect to your system on port 22. If you are still facing issues, check for other reasons defined below.

2. Check SSH Service is Active and Running

Generally, the SSH service is started automatically after the installation. But might be service is stopped due to some reason. To check the current status of the SSH service, execute:

sudo systemctl status ssh 

If the SSH service is not running or not active, use the below-mentioned commands to enable service on system startup and start service.

sudo systemctl enable ssh 
sudo systemctl start ssh 

Once the service is started successfully, you can connect to your system over ssh. In case, you still face the same error, check for the next possible issue.

3. SSH service is running on a different port

Might be the SSH service is listening on a different port. That is also a best practice for securing servers. You can find out the SSH server port by running the following command.

ss -tulpn | grep ssh 
Check SSH Port
Check ssh port

The above screenshot shows that the SSH service is listening on port 2222. You should connect the remote system with SSH on port 22. We can define a port number with an SSH connection as the below-mentioned command.

ssh -p 2222 root@192.168.1.210 

Hope this will resolve your issue. If still you are facing the same issue, check the below suggestion.

4. SSH port is blocked by the firewall

This is the most common cause that the firewall is blocking the requests.

Now, you need to identify, what firewall are you using. If the remote system is on the cloud hosting, check the security group of that hosting.

On the systems with physical access, can check if UFW or Firewalld is active.

  • Using UFW
  • Check the status of the UFW firewall with the below command:

    sudo ufw status 
    

    If the firewall is in an active state, you can open Port 22 with the below-mentioned command.

    sudo ufw allow 22/tcp 
    
  • Using FirewallD
  • Check if the firewalld daemon is active and running:

    sudo systemctl status firewalld 
    

    If the output shows Active: active (running), then you can open the SSH port by running the following command.

    sudo firewall-cmd --permanent --zone=public --add-port=80/tcp   
    

    Then reload the firewall to apply changes.

    sudo firewall-cmd --reload  
    

Conclusion

In this blog post, we have discussed four possible issues for the error “Port 22: Connection refused”. Also provides the solutions for each issue. Hope this tutorial help to resolve your issue.

If you found any other reason for this issue, please mention it in the comment.

The post (Resolved) SSH Connection Refused on Ubuntu & Debian appeared first on TecAdmin.

]]>
https://tecadmin.net/resolved-port-22-connection-refused-on-ubuntu-debian/feed/ 0
How to Install or Update OpenSSH in CentOS and Fedora https://tecadmin.net/install-or-update-openssh-server-centos-rhel-and-fedora/ https://tecadmin.net/install-or-update-openssh-server-centos-rhel-and-fedora/#comments Wed, 08 Jan 2014 12:33:54 +0000 https://tecadmin.net/?p=3875 OpenSSH is a free tool widely used for remote login or remote file transfer. It uses SSH/SecSH protocol suite to provide encryption for network services. Its source code is available free to everyone. This article will help you to Install or Update OpenSSH Server in CentOS, RHEL, and Fedora systems. Features of OpenSSH Open Source [...]

The post How to Install or Update OpenSSH in CentOS and Fedora appeared first on TecAdmin.

]]>
OpenSSH is a free tool widely used for remote login or remote file transfer. It uses SSH/SecSH protocol suite to provide encryption for network services. Its source code is available free to everyone. This article will help you to Install or Update OpenSSH Server in CentOS, RHEL, and Fedora systems.

Install or Update OpenSSH Server

Features of OpenSSH

    • Open Source Project
    • Free Licensing
    • Strong Encryption (3DES, Blowfish, AES, Arcfour)
    • X11 Forwarding (encrypt X Window System traffic)
    • Port Forwarding (encrypted channels for legacy protocols)
    • Strong Authentication (Public Key, One-Time Password, and Kerberos Authentication)
    • Agent Forwarding (Single-Sign-On)
    • Interoperability (Compliance with SSH 1.3, 1.5, and 2.0 protocol Standards)
    • SFTP client and server support in both SSH1 and SSH2 protocols.
    • Kerberos and AFS Ticket Passing
    • Data Compression

Click here to know more details about OpenSSH features.

Step 1 – Install / Update OpenSSH Server

OpenSSH Server is available under default yum repositories. We can install or update the latest OpenSSH server using the following command available under yum repositories.

On CentOS/RHEL 7 Systems:

sudo yum install openssh-server 

On Fedora and CentOS/RHEL 8 Systems:

sudo dnf install openssh-server 

Step 2 – Start OpenSSH Service

After installing or upgrading OpenSSH’s latest rpm packages, start the service using the following command and make it autostart on system boot.

sudo systemctl enable sshd 
sudo systemctl restart sshd 

Step 3 – Open Port in Firewall

If you are using iptables to secure your server, use the following command to open port for SSH access.

iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 22 -j ACCEPT 

What Next: 5 Tips to secure openssh-server

The post How to Install or Update OpenSSH in CentOS and Fedora appeared first on TecAdmin.

]]>
https://tecadmin.net/install-or-update-openssh-server-centos-rhel-and-fedora/feed/ 6