Knowledgebase

Troubleshooting SSH Connection Refused

Encountering an "SSH Connection Refused" error can be frustrating for server administrators. This error typically occurs when the server is inaccessible via SSH, potentially due to misconfigurations or network issues. This knowledge base provides detailed information on how to troubleshoot and resolve SSH connection refused errors in WHM cPanel.

  1. Understanding SSH and Connection Refused:

    • SSH (Secure Shell) is a protocol for securely accessing a remote server. The "Connection Refused" error indicates that the server is rejecting the SSH connection request.

  2. Accessing WHM for Troubleshooting:

    • Log in to WHM using your administrator credentials.

  3. Checking SSH Service Status:

    • Navigate to 'Service Status' in WHM to verify if the SSH service is running.

    • If it's not running, start the service.

  4. Confirming SSH Port:

    • Ensure that SSH is running on the default port 22, unless you have explicitly changed it.

  5. Checking Firewall Rules:

    • Verify that your server's firewall (e.g., CSF, iptables) is not blocking incoming connections on the SSH port.

  6. Whitelisting IP Addresses:

    • If your server uses a firewall, ensure that your IP address is whitelisted to allow SSH connections.

  7. Verifying SSH Configuration Files:

    • Access the server via WHM's terminal or an alternative method and check the SSH configuration files (/etc/ssh/sshd_config).

    • Confirm that the file contains valid configuration settings.

  8. Ensuring SSH Daemon is Running:

    • Use the command ps aux | grep sshd to check if the SSH daemon process is running.

  9. Checking for Fail2Ban or Other Intrusion Prevention Tools:

    • If Fail2Ban or similar tools are installed, ensure they are not blocking your IP address due to too many failed login attempts.

  10. Confirming SSH Key Authentication (Optional):

    • If using SSH key authentication, ensure that your public key is correctly added to the ~/.ssh/authorized_keys file.

  11. Disabling Password Authentication (Optional):

    • For enhanced security, consider disabling password authentication in the SSH configuration file and relying solely on key-based authentication.

  12. Restarting SSH Service:

    • If you made changes to the SSH configuration, restart the SSH service for the changes to take effect.

  13. Verifying Network Connectivity:

    • Ensure that your server has an active internet connection and that it can communicate on the SSH port.

  14. Checking for Server Overload:

    • High server load or resource exhaustion can lead to SSH connection issues. Use WHM's 'Server Status' section to monitor system resources.

  15. Reviewing System Logs:

    • Access WHM's 'Server Configuration' section and review logs like /var/log/messages and /var/log/secure for any relevant error messages.

  16. Checking for DNS Issues:

    • Ensure that the server's hostname resolves correctly both locally and externally.

  17. Verifying Firewall Rules on the Server:

    • Use the command iptables -L to list current firewall rules. Make sure they do not block SSH access.

  18. Checking SELinux Status (Optional):

    • If SELinux is enabled, verify that it is not blocking SSH connections.

  19. Accessing Emergency Console (Optional):

    • If all else fails, consider using an emergency console provided by your hosting provider to access the server directly.

  20. Contacting Hosting Support (If Applicable):

    • If the issue persists, consider reaching out to your hosting provider's support team for further assistance.

  21. Documenting Troubleshooting Steps:

    • Keep detailed records of the troubleshooting steps you have taken, which can be helpful for future reference.

Conclusion:

Troubleshooting SSH connection refused errors in WHM cPanel requires a systematic approach. By following the steps outlined in this knowledge base, you can identify and resolve the underlying issues causing the SSH connection problem. This ensures that you can regain secure access to your server for administration purposes.

 

  • 0 Users Found This Useful
Was this answer helpful?