Linux SSH – Resolving Operation Timeout When Attempting to SSH to Server

debianlinuxsshtimeout

I was transferring a file between two remote machines when the scp command stopped at 92%. When I went in to retry it, I realized that I could no longer ssh into the server. However, I do have access via my server host's VNC terminal.

I tried restarting sshd, doing a systemctl reboot, and shutting down/restarting the server from my host's web panel, but I'm still unable to SSH into the server. I've also checked /var/log/auth.log and it hasn't logged anything about the connection timeouts.

I disabled the server firewall completely (iptables) and the output of systemctl status sshd shows that it is working and listening on port 22.

Output of iptables -L:

Chain INPUT (policy ACCEPT)
Chain FORWARD (policy ACCEPT)
Chain OUTPUT (policy ACCEPT)

I have been able to ssh into other servers just fine from my machine. The output of my SSH command with -vvv is:

OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to <server-ip> port 22.
ssh: connect to host <server-ip> port 22: Operation timed out

In addition, as mentioned in some other related questions here, I manually started sshd on port 42 with /usr/sbin/sshd -p 42 -d and attempted to connect, but the connection still timed out from my local machine and no output was logged to the terminal.

As per a suggestion in the comments, I ran ssh user@localhost from within my VNC terminal, and that worked. So it appears that ssh is working for localhost, but no other users can connect from outside. Seems like a firewall issue, but I've opened up all my iptables rules.

Update:
SSH randomly started working for about 30 minutes with no changes. I was able to copy the file over that I needed to. Then, shortly after, the connection froze and disconnected me, and it's back to not working again.

Best Answer

Looks like a network issue, Operation timed out usually means that ssh was not able establish connection. What type of hosting do you use?