visual-studio-codesshcloudflarevscode-remote

How to use VS Remote SSH with Cloudflare proxied domain?


I have a server running SSH server it has a public ip and subdomain (sub.domain.tl) pointing to it using cloudflare.

In terminal I can connect using the command pointing to the public IP or the domain ssh user@1.2.3.4.5.6 or ssh user@sub.domain.tl but VS code remote SSH plugin works with IP only or then I set the subdomain be DNS only (aka no IP protection by Cloudflare).

Is there a way to configure Cloudflare or/and VS Code remote to use Cloudflares proxied domain with VS Code remote SSH?

Here is the log:

[11:01:14.627] Log Level: 2
[11:01:14.630] remote-ssh@0.70.0
[11:01:14.630] win32 x64
[11:01:14.632] SSH Resolver called for "ssh-remote+sub.domain.tl", attempt 1
[11:01:14.632] "remote.SSH.useLocalServer": false
[11:01:14.633] "remote.SSH.showLoginTerminal": false
[11:01:14.633] "remote.SSH.remotePlatform": {"1.2.3.4.5.6":"linux"}
[11:01:14.633] "remote.SSH.path": undefined
[11:01:14.633] "remote.SSH.configFile": undefined
[11:01:14.633] "remote.SSH.useFlock": true
[11:01:14.634] "remote.SSH.lockfilesInTmp": false
[11:01:14.634] "remote.SSH.localServerDownload": auto
[11:01:14.634] "remote.SSH.remoteServerListenOnSocket": false
[11:01:14.634] "remote.SSH.showLoginTerminal": false
[11:01:14.634] "remote.SSH.defaultExtensions": []
[11:01:14.634] "remote.SSH.loglevel": 2
[11:01:14.634] "remote.SSH.serverPickPortsFromRange": {}
[11:01:14.635] "remote.SSH.enableDynamicForwarding": true
[11:01:14.635] "remote.SSH.serverInstallPath": {}
[11:01:14.636] SSH Resolver called for host: sub.domain.tl
[11:01:14.636] Setting up SSH remote "sub.domain.tl"
[11:01:14.662] Using commit id "899d46d82c4c95423fb7e10e68eba52050e30ba3" and quality "stable" for server
[11:01:14.667] Install and start server if needed
[11:01:16.441] Checking ssh with "ssh -V"
[11:01:16.487] > OpenSSH_for_Windows_8.1p1, L
[11:01:16.487] > ibreSSL 3.0.2

[11:01:16.492] Running script with connection command: ssh -T -D 63859 "sub.domain.tl" bash
[11:01:16.496] Terminal shell path: C:\Windows\System32\cmd.exe
[11:01:16.741] > ]0;C:\Windows\System32\cmd.exe
[11:01:16.741] Got some output, clearing connection timeout
[11:01:22.568] > [8;12;117t
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
[11:01:59.301] > ssh: connect to host sub.domain.tl port 22: Connection timed out
> The process tried to write to a nonexistent pipe.
[11:02:00.211] "install" terminal command done
[11:02:00.211] Install terminal quit with output: ssh: connect to host sub.domain.tl port 22: Connection timed out
[11:02:00.212] Received install output: ssh: connect to host sub.domain.tl port 22: Connection timed out
[11:02:00.213] Resolver error: Error: The connection timed out
    at Function.Offline (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:430476)
    at c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:428129
    at Object.t.handleInstallOutput (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:428404)
    at Object.t.tryInstall (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:524212)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:487216
    at async Object.t.withShowDetailsEvent (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:490561)
    at async Object.t.resolve (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:488295)
    at async c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.70.0\out\extension.js:1:564197
[11:02:00.218] ------




[11:05:35.830] ConfigFileWatcher: start watching file:///c%3A/Users/user/.ssh/config
[11:05:35.830] ConfigFileWatcher: adding save listener
[11:05:35.831] ConfigFileWatcher: adding close listener
[11:05:42.507] ConfigFileWatcher: saving file:///c%3A/Users/user/.ssh/config
[11:05:42.507] ConfigFileWatcher: firing change event for file:///c%3A/Users/user/.ssh/config

Solution

  • When your domain is proxied (orange cloud) through Cloudflare, you wouldn't be able to SSH using the domain name. Not sure how your Terminal was able to do that; could be DNS cache of when the domain wasn't proxied perhaps.

    You can always SSH using IP, and there's a few ways for you to SSH using domain when using Cloudflare: