cloudflared icon indicating copy to clipboard operation
cloudflared copied to clipboard

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

Open GDivino opened this issue 1 year ago • 3 comments

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
  1. Install cloudflared on client machine (brew install cloudflared)
  2. Run ssh <username>@ssh.example.com
  3. 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

  • OS: MacOS
  • Architecture: M2
  • Version: Sonoma 14.4.1

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

GDivino avatar Apr 13 '24 05:04 GDivino

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

SimonNie98 avatar May 07 '24 09:05 SimonNie98

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.

adithayyil avatar May 15 '24 19:05 adithayyil

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

SimonNie98 avatar May 17 '24 07:05 SimonNie98