【问题标题】:How to use VS Remote SSH with Cloudflare proxied domain?如何在 Cloudflare 代理域中使用 VS Remote SSH?
【发布时间】:2022-02-01 21:23:27
【问题描述】:

我有一个运行 SSH 服务器的服务器,它有一个公共 ip 和使用 cloudflare 指向它的子域 (sub.domain.tl)。

在终端中,我可以使用指向公共 IP 或域 ssh user@1.2.3.4.5.6 或 ssh user@sub.domain.tl 的命令进行连接,但 VS 代码远程 SSH 插件仅适用于 IP,或者我设置子域只能是 DNS(也就是 Cloudflare 没有 IP 保护)。

有没有办法配置 Cloudflare 或/和 VS Code 远程以使用 Cloudflares 代理域和 VS Code 远程 SSH?

这是日志:

[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

【问题讨论】:

    标签: visual-studio-code ssh cloudflare vscode-remote


    【解决方案1】:

    当您的域通过 Cloudflare 代理(橙色云)时,您将无法使用该域名进行 SSH。不确定您的终端是如何做到这一点的;可能是域未代理时的 DNS 缓存。

    您始终可以使用 IP 进行 SSH,在使用 Cloudflare 时,您可以通过以下几种方式使用域进行 SSH:

    【讨论】:

      猜你喜欢
      • 2022-10-15
      • 2020-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-08
      • 2021-04-25
      • 1970-01-01
      相关资源
      最近更新 更多