Fail to ssh to pc via Cloudflare tunnel

Hi, everyone. I know many people have faced this problem before.
I got the error message “kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535” while ssh to my pc from terminal but it works on browser rendering. I’ve searched for many solution but there’s still no a solution can fix the problem.

Here is my ssh config
SSH global config
SSH config

And the log

ssh -v server
OpenSSH_9.4p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/sonodakazuto/.ssh/config
debug1: Reading configuration data /Users/sonodakazuto/.ssh/ssh.d/GitHub
debug1: Reading configuration data /Users/sonodakazuto/.ssh/ssh.d/server
debug1: /Users/sonodakazuto/.ssh/ssh.d/server line 1: Applying options for server
debug1: /Users/sonodakazuto/.ssh/config line 3: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Executing proxy command: exec $(which cloudflared) access ssh --hostname (I don't want to show)
debug1: identity file /Users/sonodakazuto/.ssh/server type 3
debug1: identity file /Users/sonodakazuto/.ssh/server-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.4
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535

Try to modify your SSH configuration to specify the specific key exchange algorithm. Add the following line in your .ssh/config file
KexAlgorithms +diffie-hellman-group1-sha1
after that try to debug using -vvv

Thank you for reply. Actually I found some problem with cloudflared configuration after post this. I remove the whole .cloudflared directory in my home directory and then it works.

1 Like