SSH "Connection closed by UNKNOWN port 65535": the ProxyJump or ProxyCommand failed
UNKNOWN port 65535 means ssh was talking through a jump host or ProxyCommand, not a direct socket, and that link closed. The real error is on the lines above.
Connection closed by UNKNOWN port 65535
This line does not name a real port. When ssh reaches the host through ProxyJump (-J) or ProxyCommand, it talks to a pipe instead of a network socket, so it has no address or port to print. OpenSSH then shows UNKNOWN and 65535 as placeholders. The message only says that the link through the proxy closed before the SSH session could start.
Read the lines above it
The useful error is printed just before this line, often by the jump host or by the proxy command:
channel 0: open failed: connect failed: Connection refusedfollowed bystdio forwarding failed: you reached the jump host, but the jump host could not connect to the target. Check the target's name and port as the jump host sees them, and whether SSH runs there. A name the jump host cannot resolve can giveconnect failed: Name or service not knowninstead. These lines do not always appear; if you see only the UNKNOWN line, run again with-v.ssh: connect to host jump.example.com port 22: Connection refused(or a timeout): the jump host itself could not be reached.Host key verification failed.orPermission denied: logging in to the jump host failed. See Host key verification failed through a jump host (ProxyJump).- Nothing above it: the proxy command exited without an error message. Run it by hand to see what it does. ssh starts the proxy command, and the hidden
ssh -Wbehind-J, through the shell named in yourSHELLvariable. If that is a no-login shell, as for some service accounts, the command never runs and you see only the UNKNOWN line. SetSHELL=/bin/shfor the job.
You may also see kex_exchange_identification: Connection closed by remote host just before it. That only says the link closed before the target's SSH greeting arrived; the causes are the same as above, or the target's sshd closed the connection itself. See SSH banner exchange errors, "Connection closed" and "timed out during banner exchange".
Get more detail
Run ssh -v -J [email protected] [email protected]. With -J, ssh starts a second ssh for the jump host. Settings you give with -o on the command line are not passed to that one, so put jump host settings in a Host block in ~/.ssh/config.
Exit status is 255 in all of these cases. See ssh exits with status 255: an SSH error, not your remote command.
Related
- Jump hosts (ProxyJump)
- Host key verification failed through a jump host (ProxyJump)
- SSH banner exchange errors, "Connection closed" and "timed out during banner exchange"
- SSH "channel 3: open failed: connect failed: Connection refused" with port forwarding
- ssh exits with status 255: an SSH error, not your remote command
- SSH error messages, what each one means