How to troubleshoot SSH connectivity issues

How to troubleshoot SSH connectivity issues

Posted on |

SSH (Secure Shell or Secure Socket Shell) is a service that enables clients and system administrators to visit a server securely across an insecure network. In some circumstances, the host cannot be reached through SSH, or the SSH service refuses the link, which must be checked further.

Whenever you begin debugging SSH, you must ensure that:

There have been no SSH connection limitation rules configured on the router level in the LayerPanel or on the server, i.e SSH not working. As seen below, your server is operational via the Terminal in the LayerPanel.

The suggestions below might be used to troubleshoot difficulties with SSH not working.

Fixing SSH Connection Problems: SSH not working

Error Identifying Remote Hostname

When attempting to access using SSH, you may encounter the following errors:

Remote Host Identification Has Changed

OR  

ssh: Could not resolve hostname: Name or service not known  

OR  

Unable to open a connection to Host does not exist

When a server refuses to access SSH using a specified network address, a hostname issue may result.

To correct such inaccuracies, follow the instructions below:

  • Verify that the hostname is accurate.
  • Check to see if the hostname supports ping.
  • If the hostname does not resolve successfully, you could use the public IP address for SSH as shown below, in which the client is the SSH username you use because the server IP is 123.123.123.123.

# ssh user@123.123.123.123

Error with Connection Timeout

This issue occurs when a user attempts to access the server however the server fails to test the link within the delay period set.

In such instances, the following are the most prevalent error code:

Error output

ssh: connect to host 123.123.123.123 port 22: connection timed out

OR 

PuTTY error output

Network error: Connection time out

Follow the instructions below to rectify this mistake.

  • Check that the site’s IP address is appropriately entered.
  • Ascertain that your system supports SSH port connection.
  • Check that your VPS’s security protocols are never to blame.

The recommendations below may be utilised to resolve SSH not working issues.

Connection Error

Connectivity loss and delay are not the same things. Once your SSH request reaches the SSH port, the server refuses to admit it, you have a connectivity failure.

In this instance, you may get the following errors:

Error output

ssh: connect to host 123.123.123.123 port 22: connection refused

OR

PuTTY error output

Network error: Connection refused

The methods for resolving connection loss are similar to those for resolving connection timeout. Use the instructions below to rectify this mistake.

  • Check that the server’s IP address is accurate.
  • Confirm that SSH connections are permitted on your network.
  • Check that the server firewall rules permit SSH access.

Checking the Firewall Configuration

One of the most prevalent reasons for SSH not working is firewall blocking, and firewall programmes vary depending on the server’s operating system. It is firewalled on CentOS7, however, it is ufw in Ubuntu. If they are not available on the server, it is most likely running iptables.

# iptables -nL

If you have any REJECT or DROP restrictions, make sure the INPUT chain accepts the standard SSH port 22.

The function below displays a list of the domains that the firewall supports.

# firewall-cmd  —list-services

sshtbs3

You may use the —list-ports argument to see whether you’re using a custom SSH port.

The following command may be used to verify the firewall rules on Ubuntu systems with ufw loaded.

# ufw status

SSH Checking Status

If you are having trouble getting to a server through SSH, the very first step you should do is to ensure that the SSH server is up and operating. To monitor the validity of the SSH session on the server, use the instructions shown below.

Just use the process command on earlier operating systems such as Ubuntu 14.04, Debian 8, or CentOS 6.

# ssh service status

Use the systemctl function to upgrade to a newer version.

# status sshd systemctl

If somehow the SSH not working or functional, the following instructions, depending on the operating system, could be used to restart it.

# service ssh start OR systemctl start sshd

SSH Port Verification

In all operating systems, the standard SSH port is 22. You could also utilise a unique SSH port, which can be defined in the SSH service’s config file, found at the path /etc/ssh/sshd config.

To verify the SSH port on the host, use the following command:

# grep -i /etc/ssh/sshd config port

You may also use the netstat query to see what port the SSH service is using. Execute the following command, and the result should be visible in the SSH port.

grep sshd | netstat -ntlp

The suggestions below might be used to troubleshoot difficulties with SSH not working.

Checking to see whether Root Login is allowed

The SSH service can be set to prevent root usernames and passwords. Run the following command to see if root access is authorised or not:

# PermitRootLogin /etc/ssh/sshd config grep

If it is not allowed, change the value of PermitRootLogin in /etc/ssh/sshd config to yes, reboot SSH, and try signing in as root afresh.

To resume the SSH service, use the code below.

# restart systemctl sshd 

OR 

sshd 

Checking to see whether Password Authentication is supported

SSH may be set to accept or reject passwords in favour of public-key verification. Run the following command to see if password protection is empowered:

Run the following command to see if password protection is empowered:

Change the PasswordAuthentication setting in /etc/ssh/sshd config to yes, reboot SSH, and try signing in with your login afresh.

To restore the SSH service, use the command below.

# service restart sshd OR # systemctl restart sshd restart ssh

Examining the SSH public key saved on the server

If you are unable to log in to your website utilizing public-key security, check to see whether the key pair has been configured on your server.

Use the following command to examine the public keys saved on your server.

/.ssh/authorized keys cat

If your public key is not already included in this document, add it on a new line.

The location of the authorised keys on some sites may vary. To find the file, use the following command: 

To find the file, use the following command: 

The server’s standard SSH port is 22, and altering it adds an additional layer of protection to the server by lowering the possibility of automated assaults.

Please keep in mind that port numbers ranging from 0 to 1023 are allocated for various system functions. As a result, the suggested ports might employ port numbers ranging from 1024 to 65535.

# vi /etc/ssh/sshd config find the line Port 22 OR #Port 22 in the sshd config file and add a new Terminal.

And afterwards, update the port number to the one you wish to be using and save the document.

Now, activate the SSH services on the host with the following instructions, which vary depending on the operating system.

# service ssh restart OR # systemctl restart sshd

The suggestions below might be used to troubleshoot difficulties with SSH not working.

Add a new SSH port to the server firewall rules.

The standard firewall for Ubuntu is UFW, and to create a new filter, use the following code.

# sudo ufw permit 4444/tcp

The standard firewall for CentOS is FirewallD, and to create a new filter, use the following code.

# firewall-cmd —permanent —public-zone —add-port=4444/tcp

# firewall-cmd —force-reload

Use the updated SSH port to connect to the server.

When connecting to the host from the SSH client terminal, kindly use the “-p” option () to indicate the port.

# ssh username@server IP -p 4444

Use the fresh SSH port to connect to the server.

When connecting to the server from the SSH client terminal, must use the “-p” option () to indicate the port.

# ssh username@server IP -p 4444

So this is how you have to fix the SSH not working issues. The suggestions above might be used to troubleshoot difficulties with SSH not working.

DataServerMarket

DataServerMarket can help you find connection solutions for your IT difficulties. DataServerMarket develops shared facilities that may be utilised on-site by a range of clients.

The following are some of the services offered by DataServerMarket:

  • DataServerMarket connects different clouds and digital storage locations for faster connectivity.
  • DataServerMarket offers data and processing connection options for businesses.
  • DataServerMarket additionally offers expert professional advice, as well as electronic adaptability and connectivity services.
  • DataServerMarket also offers cloud video conferencing, global telephony services, and IP communication between customers and Service Providers.
  • DataServerMarket provides storage options, Vpn Clouds, personal email solutions, relocation, and data transmission solutions.

DataServerMarket develops shared rooms that may be utilised on-site by a range of clients. DataServerMarket connects different clouds and data storage locations for faster connectivity. DataServerMarket also offers cloud videography, global telecommunication services, and IP connection between customers and Service Providers. DataServerMarket provides storage options, Vpn Clouds, private mail solutions, migration, and file transfer options.

Leave a Reply

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