cloudflare / cloudflared

Cloudflare Tunnel client (formerly Argo Tunnel)
https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide
Apache License 2.0
9.1k stars 798 forks source link

Getting an error of zsh: no such file or directory when SSHing using cloudflared 🐛 #1231

Open GDivino opened 6 months ago

GDivino commented 6 months ago

Describe the bug I want to be able to SSH into my raspberry pi from anywhere using cloudflare tunnels. But I ran into a road block, receiving an error of zsh: no such file or directory every time I ran ssh <username>@ssh.example.com. I am using MacOS as my client, and I run raspbian OS on my raspberry pi. I followed these docs religiously but for some reason I can't get past this error (see logs below for full error log).

To Reproduce Steps to reproduce the behavior (basically follow everything here):

  1. Import a domain into cloudflare or buy a domain through cloudflare
  2. Create a website project with that domain
  3. Set up the tunnel (through dashboard)
  4. Install and start the cloudflared service in the server with the command given in the dashboard
  5. Edit your client's ssh config (~/.ssh/config) with:
    Host ssh.example.com
    ProxyCommand /opt/homebrew/bin/cloudflared access ssh --hostname %h
  6. Install cloudflared on client machine (brew install cloudflared)
  7. Run ssh <username>@ssh.example.com
  8. See error

Expected behavior I expect cloudflared to open up a browser authentication screen, using my cloudflare account as authentication. Once I authenticate properly, I am able to ssh into my raspberry pi.

Environment and versions

Logs and errors

debug1: Executing proxy command: exec /usr/local/bin/cloudflared access ssh --hostname ssh.example.com
debug1: identity file /Users/gdivino/.ssh/id_rsa type -1
debug1: identity file /Users/gdivino/.ssh/id_rsa-cert type -1
debug1: identity file /Users/gdivino/.ssh/id_ecdsa type -1
debug1: identity file /Users/gdivino/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/gdivino/.ssh/id_ecdsa_sk type -1
zsh: No such file or directory
debug1: identity file /Users/gdivino/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /Users/gdivino/.ssh/id_ed25519 type -1
debug1: identity file /Users/gdivino/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/gdivino/.ssh/id_ed25519_sk type -1
debug1: identity file /Users/gdivino/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /Users/gdivino/.ssh/id_xmss type -1
debug1: identity file /Users/gdivino/.ssh/id_xmss-cert type -1
debug1: identity file /Users/gdivino/.ssh/id_dsa type -1
debug1: identity file /Users/gdivino/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.6
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
SimonNie98 commented 5 months ago

I also met this bug. I have installed cloudflared via brew install cloudflared and I can access my remote server via ssh, but when I try to use VSCode to ssh to my server, the log shows:

local-server-1> Spawned ssh, pid=62656 OpenSSH_9.6p1, LibreSSL 3.3.6 OpenSSH_9.6p1, LibreSSL 3.3.6 zsh:1: command not found: cloudflared kex_exchange_identification: Connection closed by remote host Connection closed by UNKNOWN port 65535 kex_exchange_identification: Connection closed by remote host Connection closed by UNKNOWN port 65535 local-server-1> ssh child died, shutting down

adithayyil commented 5 months ago

Hey @GDivino, have you perhaps found a workaround for this issue? I was connecting without any problems until yesterday, so something seems to have gone wrong.

SimonNie98 commented 5 months ago

Update: I solved this problem by first locating the installed path of cloudflared via whereis cmd and then modifying the ssh config files and replacing the cloudflared command with the full path.

I also met this bug. I have installed cloudflared via brew install cloudflared and I can access my remote server via ssh, but when I try to use VSCode to ssh to my server, the log shows:

local-server-1> Spawned ssh, pid=62656 OpenSSH_9.6p1, LibreSSL 3.3.6 OpenSSH_9.6p1, LibreSSL 3.3.6 zsh:1: command not found: cloudflared kex_exchange_identification: Connection closed by remote host Connection closed by UNKNOWN port 65535 kex_exchange_identification: Connection closed by remote host Connection closed by UNKNOWN port 65535 local-server-1> ssh child died, shutting down