cloudflared icon indicating copy to clipboard operation
cloudflared copied to clipboard

Cannot connect in cloudflared ssh

Open 0xspade opened this issue 2 years ago • 5 comments

Hi,

I watch the tutorial for setting up the cloudflared ssh, I already run the cloudflared as ssh. BTW, my server is a Linux, and the client is windows. whenever I connect to ssh like: ssh [email protected] I always get, this error:

failed to find Access application at https://cloudflared.myhost.me
kex_exchange_identification: Connection closed by remote host

I guess that my problem is in my windows setup, I also tried connecting using Putty and it doesn't work. I manually put this to my .ssh folder in my windows:

Host cloudflared.myhost.me
  ProxyCommand cloudflared access ssh-gen --hostname %h && cloudflared access ssh --hostname %h

Note: cloudflared.myhost.me is just an example domain, not my real domain :)

0xspade avatar Nov 09 '21 07:11 0xspade

I did try visiting the https://cloudflared.myhost.me and it prompts me a login and I can confirm that it's working.

0xspade avatar Nov 09 '21 07:11 0xspade

Hey! any solution for this? I'm encountering a similar problem, have a linux server and am trying to connect via a windows client but it doesn't connect at all, though with all the configuration kept unchanged, it works just fine from another linux client. :|

I'm trying to setup a remote vscode-server on linux and run the vscode client on windows.

shreyasmiraj avatar Jan 10 '22 19:01 shreyasmiraj

@0xspade I think I got it working, came across a post that suggested using full path to ssh.exe for ProxyCommand so thought of trying the same thing here but instead for the cloudflared.exe and it worked as expected! So you need to replace cloudflared call with its full path instead.

Host cloudflared.myhost.me
  ProxyCommand C:\Users\me\Downloads\cloudflared.exe access ssh-gen --hostname %h && \ 
  C:\Users\me\Downloads\cloudflared.exe access ssh --hostname %h

shreyasmiraj avatar Jan 10 '22 21:01 shreyasmiraj

Fix :-

Most common Mistakes

  • not includeing all pre-authorised usrs & grps to App Launcher ( in settings , not in access > application )

  • don't enable This If U Wanna Access SSH Via CLI

  • Cloudflare Zero Trust

LHS Menu - Access > Applications >

${_App_Name_} > Settings >

Tab - 2 - Cookie settings > Option - 3 - Enable Binding Cookie ( Binds the user's browser to Cloudflare's edge. Protects against stolen authorization cookies. )

Some How This Binding Option Is Doing Something Which Prevents Ssh connection to get connected

What Did It Cost

3 Days ( 16~14 Hr / Day ) : 6 Hr : ~40 Minutes

Just Because Some One Good At Cloudflare Is Extream Bizzy In Development ( Full Respect To Him ) , But Man Why Every Time Such Cutting Edge Peace Of Program Lac So Important Guide/Tutorial

U Can At Least Describe The All features in blog as a paragraph or even audio notes , in short plz fr fske make proper docs 🤬🤬🤬

ghost avatar Jun 17 '22 13:06 ghost

Thank you @MOOGAA for that tip, I was struggling with a "websocket: bad handshake" today and disabling "Enable Binding Cookie" was the cause of the error.

I created an issue in the https://github.com/cloudflare/cloudflare-docs repository to fix this: https://github.com/cloudflare/cloudflare-docs/issues/5654

etec-masterofsynapse avatar Aug 28 '22 12:08 etec-masterofsynapse

for my case, the latest cloudflared just use tcp instead of ssh.

Host cloudflared.myhost.me
  HostName cloudflared.myhost.me
  ProxyCommand cloudflared access tcp --hostname %h
  User me

kid1412621 avatar May 23 '23 14:05 kid1412621