V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
GoodRui
V2EX  ›  Visual Studio Code

vs code 又搞幺蛾子了? ssh remote 无法远程连接带中文名的主机了呢?

  •  
  •   GoodRui · 246 天前 · 1217 次点击
    这是一个创建于 246 天前的主题,其中的信息可能已经有所发展或是发生改变。

    没注意从哪天,反正是最近 2 、3 周开始,使用 ssh remote 远程的时候无法连接 host 名中有中文字符的主机了呢?用 Mac 和 Windows 的测试都不行了... 搜了下也没人讨论,是我个人问题吗?

    7 条回复
    march1993
        1
    march1993  
       246 天前
    日志贴上来看一下
    GoodRui
        2
    GoodRui  
    OP
       246 天前
    多次尝试了下,发现是 Mac 的连不了,Windows 的可以正常连...
    GoodRui
        3
    GoodRui  
    OP
       246 天前
    @march1993
    ```bash
    [14:43:37.256] Log Level: 2
    [14:43:37.261] SSH Resolver called for "ssh-remote+测试.63", attempt 1
    [14:43:37.262] "remote.SSH.useLocalServer": true
    [14:43:37.262] "remote.SSH.useExecServer": true
    [14:43:37.262] "remote.SSH.path": undefined
    [14:43:37.262] "remote.SSH.configFile": undefined
    [14:43:37.262] "remote.SSH.useFlock": true
    [14:43:37.262] "remote.SSH.lockfilesInTmp": false
    [14:43:37.262] "remote.SSH.localServerDownload": auto
    [14:43:37.263] "remote.SSH.remoteServerListenOnSocket": false
    [14:43:37.263] "remote.SSH.showLoginTerminal": false
    [14:43:37.263] "remote.SSH.defaultExtensions": []
    [14:43:37.263] "remote.SSH.loglevel": 2
    [14:43:37.263] "remote.SSH.enableDynamicForwarding": true
    [14:43:37.263] "remote.SSH.enableRemoteCommand": false
    [14:43:37.263] "remote.SSH.serverPickPortsFromRange": {}
    [14:43:37.263] "remote.SSH.serverInstallPath": {}
    [14:43:37.265] VS Code version: 1.87.2
    [14:43:37.265] Remote-SSH version: [email protected]
    [14:43:37.265] darwin arm64
    [14:43:37.270] SSH Resolver called for host: 测试.63
    [14:43:37.270] Setting up SSH remote "测试.63"
    [14:43:37.272] Acquiring local install lock: /var/folders/38/b3x_cvmj52l_34zwckxg4j2h0000gn/T/vscode-remote-ssh-1fc16eca-install.lock
    [14:43:37.272] Looking for existing server data file at /Users/goodrui/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-1fc16eca-863d2581ecda6849923a2118d93a088b0745d9d6-0.109.0-es/data.json
    [14:43:37.273] Using commit id "863d2581ecda6849923a2118d93a088b0745d9d6" and quality "stable" for server
    [14:43:37.275] Install and start server if needed
    [14:43:37.281] PATH: /Users/goodrui/.local/share/zinit/polaris/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/goodrui/.local/bin:/Library/Developer/CommandLineTools/usr/bin/
    [14:43:37.281] Checking ssh with "ssh -V"
    [14:43:37.288] > OpenSSH_9.6p1, LibreSSL 3.3.6

    [14:43:37.291] askpass server listening on /var/folders/38/b3x_cvmj52l_34zwckxg4j2h0000gn/T/vscode-ssh-askpass-d4669f369821c71afa3b6e2dfe0db30c1297d72e.sock
    [14:43:37.291] Spawning local server with {"serverId":1,"ipcHandlePath":"/var/folders/38/b3x_cvmj52l_34zwckxg4j2h0000gn/T/vscode-ssh-askpass-012433f7d0f9af854f4613148a9c136d81e02100.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","58228","-o","ConnectTimeout=15","测试.63"],"serverDataFolderName":".vscode-server","dataFilePath":"/Users/goodrui/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-1fc16eca-863d2581ecda6849923a2118d93a088b0745d9d6-0.109.0-es/data.json"}
    [14:43:37.291] Local server env: {"SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.YrWms1aRZR/Listeners","SHELL":"/bin/zsh","DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin)","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"","VSCODE_SSH_ASKPASS_MAIN":"/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/var/folders/38/b3x_cvmj52l_34zwckxg4j2h0000gn/T/vscode-ssh-askpass-d4669f369821c71afa3b6e2dfe0db30c1297d72e.sock"}
    [14:43:37.292] Spawned 74826
    [14:43:37.392] > local-server-1> Running ssh connection command: ssh -v -T -D 58228 -o ConnectTimeout=15 测试.63
    [14:43:37.392] > local-server-1> Spawned ssh, pid=74832
    [14:43:37.395] stderr> hostname contains invalid characters
    [14:43:37.396] > local-server-1> ssh child died, shutting down
    [14:43:37.397] Local server exit: 0
    [14:43:37.398] Received install output: local-server-1> Running ssh connection command: ssh -v -T -D 58228 -o ConnectTimeout=15 测试.63
    local-server-1> Spawned ssh, pid=74832
    hostname contains invalid characters
    local-server-1> ssh child died, shutting down

    [14:43:37.398] Failed to parse remote port from server output
    [14:43:37.399] Resolver error: Error:
    at g.Create (/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:499734)
    at t.handleInstallOutput (/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:497056)
    at e (/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:558185)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:580094
    at async t.withShowDetailsEvent (/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:583753)
    at async /Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:554890
    at async T (/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:552941)
    at async t.resolveWithLocalServer (/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:554430)
    at async k (/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:577311)
    at async t.resolve (/Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:581124)
    at async /Users/goodrui/.vscode/extensions/ms-vscode-remote.remote-ssh-0.109.0/out/extension.js:2:847283
    [14:43:37.404] ------
    ```

    看中间 `stderr> hostname contains invalid characters`

    ssh config 配置文件中主机的配置

    ```
    Host 测试.63
    User root
    HostName 172.16.111.63
    Port 22
    ```

    我反复测试了,只要 `Host` 中有中文字符,就会报错。以前是没问题的,然后刚才用 Windows 机器测了几个也没问题。
    march1993
        4
    march1993  
       246 天前
    单独跑 `ssh -v -T -D 58228 -o ConnectTimeout=15 测试.63` 呢
    GoodRui
        5
    GoodRui  
    OP
       246 天前
    @march1993 感谢兄弟回复

    我发现是我的 mac 连接的时候提示 `hostname contains invalid characters` 了...
    这是咋整的呢...
    march1993
        6
    march1993  
       245 天前   ❤️ 1
    @GoodRui 改 PATH 环境变量,用自己编译的 ssh 顶掉系统自带的
    GoodRui
        7
    GoodRui  
    OP
       244 天前
    @march1993 感谢老哥,我发到 macOS 区了,https://www.v2ex.com/t/1026819 ,是最近 openssh 升级漏洞导致的,从 9.6p1 开始禁止 hostname 中使用特殊字符了。用 homebrew 安装了 openssh 9.5p1 问题解决了。纠结以后怎么办。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3422 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 11:37 · PVG 19:37 · LAX 03:37 · JFK 06:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.