982Mysterious SSH Connection Problem
Step before: Trying to connect to a server with a SSH key. System: OSX, Big Sur
Connecting to a Server via SSH fails:
georg@Fischer ~ % ssh trembl@myserver -v
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/georg/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to myserver.com port 22.
ssh: connect to host myserver.com port 22: Operation timed out
Did not work for ca. 1 hour. Same connection problem to different account with same provider, other account with same provider worked.
(Possible) Solution: Intentionally mis-spelled username, -v not stopping and timing out, log-in now possible.
Update 1
Use
nmap -Pn -p22 myserver
to check if the port is open or filtered.
Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower.
Starting Nmap 7.91 ( https://nmap.org ) at 2021-03-30 14:15 JST
Nmap scan report for trembl@myserver (xx.xx.xxx.xxx)
Host is up (0.21s latency).
rDNS record for xx.xx.xxx.xxx: xx.xx.xxx.xxx
PORT STATE SERVICE
22/tcp filtered ssh
It should say:
PORT STATE SERVICE
22/tcp open ssh
Update 2
Creating a ssh connection to the server from another computer (on the same network) worked. Somehow, after that check, the connection on this computer also worked. Very mysterious.
Update 3
Approach 2 did not work the next time. Switching to a different network (phone hotspot) worked. Maybe restarting the router?