I am using the OpenSSH client on Windows and trying to connect to a remote server using Cloudflare Tunnel’s executable. I must configure the server hostname in the SSH config file to match the hostname of the server that I am trying to connect to and perform additional operation. However, for whatever reason, the exec command in the config seems to be unable to recognize the command if the executable directory contains any spaces. I understand that paths with spaces need to be enclosed in quotation marks or use some escape characters when running in a terminal, but for whatever reason, nothing I tried seems to work in this case.
The code below shows how my SSH config file looks. Notice that the quotation mark enclosure works just fine for ProxyCommand, IdentityFile, and CertificateFile, but will not work for the exec command.
Match host vm.example.com exec "C:UsersUser NameProject Directorycloudflared.exe access ssh-gen --hostname %h"
HostName vm.example.com
ProxyCommand "C:UsersUser NameProject Directorycloudflared.exe" access ssh --hostname %h
IdentityFile "~/.cloudflared/vm.example.com-cf_key"
CertificateFile "~/.cloudflared/vm.example.com-cf_key-cert.pub"
I have tried multiple ways to escape this, such as using a the common escape character for double quotes, single quotes and such like below:
Match host vm.example.com exec ""C:UsersUser NameProject Directorycloudflared.exe" access ssh-gen --hostname %h"
Note that the config file (exec command) works perfectly fine when the directory contains no space. Any help in this regard will be greatly appreciated.