SSH Connection Issues to a Specific Host.

SSH Connection Issues to a Specific Host.

Applies To: Linux System 
Category: Troubleshooting Server Connectivity, Network 

Issue Summary  

Users are unable to establish an SSH connection to a specific remote host, receiving errors like “Connection refused”, “Connection timed out”, or “Permission denied.” 

Possible Cause(s)  

List common reasons why this issue may occur.  

  1. The remote host is down or unresponsive. 

  1. SSH service (sshd) is not running on the remote host. 

  1. Firewall blocking SSH port (default 22) on either client or server. 

  1. Incorrect IP address or hostname. 

  1. Network connectivity issues between client and server. 

  1. Incorrect SSH key permissions or missing keys on client/server. 

  1. Incorrect username or password. 

  1. SSH configuration issues on the server (e.g., sshd_config). 

Step-by-Step Resolution  

  1. 1. Check SSH Client Logs/Verbosity: 

    1. While taking access to the server, add a verbose flag for more details. 

    ssh -v <user>@<hostname>

  2. 2. Verify Remote Host Status: 

  1. Ping the remote host's IP address. If there is no response, the host might be down or unreachable. 

ping <hostname> 

                  If the ping command is not run, then contact the IT team.
  1. If possible, check the physical status of the remote host. 

  1. 3. Check SSH Service Status on Remote Host (if accessible by other means): 

  1. If you can access the host via console or another method, check if sshd is running. 

sudo systemctl status sshd 

  1. If sshd is not running, try starting it. 

sudo systemctl start sshd 

  1. 4. Check Network Connectivity and Port: 

  1. From the client, use telnet. If it hangs or refuses, a firewall or network issue is likely to occur. 

telnet <hostname_or_ip> 22 

  1. Check firewall rules on both client and server. 

sudo firewall-cmd --list-all  

  1. 5. Verify IP Address/Hostname: 

  1. Double-check the IP address or hostname being used. 

To check the IP address: 

ifconfig 

To check the hostname: 

hostname -f 

  1. Ensure DNS resolution is working correctly. 

nslookup <hostname>   

  1. 6. Verify Authentication Method: 

  1. Password: Ensure correct username and password. 

  1. Key-based: 

  1. Check permissions for ~/.ssh and ~/.ssh/id_rsa. They should be 700 and 600, respectively. 

sudo chmod 700 ~/.ssh 

sudo chmod 600 ~/.ssh/id_rsa 

  1. Ensure the public key is correctly added to ~/.ssh/authorized_keys on the remote host. 

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 

  1. Check permissions of ~/.ssh/authorized_keys on the remote host (should be 600). 

sudo chmod 600 ~/.ssh/authorized_keys 

  1. 7. Review sshd_config on Remote Host: 

  1. Examine /etc/ssh/sshd_config for directives that might be restricting access (e.g., AllowUsers, DenyUsers, AllowGroups, Port, PasswordAuthentication no, PermitRootLogin no). 

cat /etc/ssh/sshd_config 

  1. Restart sshd after any changes. 

sudo systemctl restart sshd 

Additional Notes: 

  • Always try to access the host from another client, if possible, to rule out client-side issues. 

  • If the issue is specific to one user, focus on their .ssh directory permissions and authorized_keys file. 

    • Related Articles

    • Hive Metastore Connection Issues with MySQL

      Hive Metastore Connection Issues with MySQL Category: Troubleshooting → Hive Metastore Applies To: Apache Hive 2.x, 3.x with MySQL Metastore Issue summary: Users or Hive services (HiveServer2, Hive CLI, Spark with Hive integration) are unable to ...
    • Remote Server Unreachable via SSH/HTTP/All Services

      Title: Remote Server Down – Step-by-Step Troubleshooting Guide Category: Troubleshooting Last Updated: 23/06/2025 Issue Summary Users are unable to connect to a remote server via SSH, HTTP, or any other service. The server appears to be unresponsive ...
    • Troubleshooting Yarn Application Failures

      Troubleshooting Yarn Application Failures Category: Troubleshooting → YARN Applies To: Apache YARN 2.x, 3.x Issues Summary: YARN applications (such as Spark, MapReduce, Tez jobs) fail to complete successfully, often exiting with a FAILED status, or ...
    • How to Debug Spark Application Logs (YARN UI)

      How to Debug Spark Application Logs (YARN UI) Category: Troubleshooting → Apache Spark Applies To: Apache Spark 2.x, 3.x running on Apache Hadoop YARN 2.x, 3.x Issue summary: When a Spark application fails on a YARN cluster, the application logs are ...
    • Resolving Delayed DataNode Initialization: Effective Strategies.

      Applies To: Hadoop HDFS DataNode Category: Troubleshooting → HDFS Issue Summary An HDFS DataNode is taking an unusually long time to start up and join the cluster, potentially delaying data availability and cluster operations. Possible Cause(s) List ...