使用SSH工具,通过IP远程连接WIN11,调用GPU算力

满足你用vscode登IDE软件的远程连接服务器的需求,不用局限于windows系统

一、远程电脑设置(Windows 11 目标机)

1. 启用 OpenSSH 服务器
# 检查是否已经安装
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
# 通过PowerShell(管理员权限)安装:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

2. 启动 SSH 服务
# 以管理员身份启动 PowerShell
Start-Service sshd
# 开机自启
Set-Service -Name sshd -StartupType Automatic
3. 防火墙配置

允许 SSH 端口,我这里使用的是2222端口:

New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 2222

# 确保防火墙规则已添加
Get-NetFirewallRule -Name *ssh*
4. 修改ssh_config配置文件
# 使用记事本编辑配置文件
notepad C:\ProgramData\ssh\sshd_config

确保以下行已取消注释(删除行首的#):

Prot 2222
PasswordAuthentication yes
PubkeyAuthentication no

保存并关闭文件后,重启SSH服务:

Restart-Service sshd
5. 验证 SSH 连接
# 利用本地机器输入以下内容看能不能连接,远程用户名可以用whoami查询
ssh 远程用户名@远程IP

二、本地电脑设置(你的机器)

1. 安装 VS Code 扩展

安装 Remote - SSH 扩展(Microsoft 官方出品)

2. 配置 SSH 连接文件
  • 创建/编辑配置文件:
notepad $env:USERPROFILE\.ssh\config

  • 粘贴以下内容(用实际参数替换):
Host DeepLearningPC
    HostName 远程IP
    User 远程用户名
    IdentityFile ~/.ssh/id_ed25519
  • 快速连接测试:
ssh DL-Win11
3. 连接远程主机
  • F1 打开 VS Code 命令面板
  • 输入 Remote-SSH: Connect to Host 选择配置好的主机

[17:04:56.015] Log Level: 2 [17:04:56.034] SSH Resolver called for "ssh-remote+183.175.12.54", attempt 1 [17:04:56.039] remote.SSH.useLocalServer = false [17:04:56.039] remote.SSH.useExecServer = true [17:04:56.039] remote.SSH.bindHost = {} [17:04:56.040] remote.SSH.showLoginTerminal = false [17:04:56.040] remote.SSH.remotePlatform = {} [17:04:56.040] remote.SSH.path = [17:04:56.040] remote.SSH.configFile = [17:04:56.042] remote.SSH.useFlock = true [17:04:56.042] remote.SSH.lockfilesInTmp = false [17:04:56.042] remote.SSH.localServerDownload = auto [17:04:56.042] remote.SSH.remoteServerListenOnSocket = false [17:04:56.042] remote.SSH.defaultExtensions = [] [17:04:56.043] remote.SSH.defaultExtensionsIfInstalledLocally = [] [17:04:56.043] remote.SSH.loglevel = 2 [17:04:56.043] remote.SSH.enableDynamicForwarding = true [17:04:56.043] remote.SSH.enableRemoteCommand = false [17:04:56.043] remote.SSH.serverPickPortsFromRange = {} [17:04:56.044] remote.SSH.serverInstallPath = {} [17:04:56.044] remote.SSH.permitPtyAllocation = false [17:04:56.044] remote.SSH.preferredLocalPortRange = undefined [17:04:56.044] remote.SSH.useCurlAndWgetConfigurationFiles = false [17:04:56.045] remote.SSH.experimental.chat = true [17:04:56.045] remote.SSH.experimental.enhancedSessionLogs = true [17:04:56.045] remote.SSH.httpProxy = {"*":""} [17:04:56.045] remote.SSH.httpsProxy = {"*":""} [17:04:56.053] VS Code version: 1.101.2 [17:04:56.053] Remote-SSH version: remote-ssh@0.120.0 [17:04:56.054] win32 x64 [17:04:56.057] SSH Resolver called for host: 183.175.12.54 [17:04:56.057] Setting up SSH remote "183.175.12.54" [17:04:56.066] Using commit id "2901c5ac6db8a986a5666c3af51ff804d05af0d4" and quality "stable" for server [17:04:56.066] Extensions to install: [17:04:56.072] Install and start server if needed [17:04:57.046] Checking ssh with "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\ssh.exe -V" [17:04:57.048] Got error from ssh: spawn C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\ssh.exe ENOENT [17:04:57.048] Checking ssh with "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\libnvvp\ssh.exe -V" [17:04:57.049] Got error from ssh: spawn C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\libnvvp\ssh.exe ENOENT [17:04:57.049] Checking ssh with "D:\python3.13.5\Scripts\ssh.exe -V" [17:04:57.050] Got error from ssh: spawn D:\python3.13.5\Scripts\ssh.exe ENOENT [17:04:57.051] Checking ssh with "D:\python3.13.5\ssh.exe -V" [17:04:57.051] Got error from ssh: spawn D:\python3.13.5\ssh.exe ENOENT [17:04:57.051] Checking ssh with "C:\Program Files\Common Files\Oracle\Java\javapath\ssh.exe -V" [17:04:57.053] Got error from ssh: spawn C:\Program Files\Common Files\Oracle\Java\javapath\ssh.exe ENOENT [17:04:57.053] Checking ssh with "C:\Program Files (x86)\VMware\VMware Workstation\bin\ssh.exe -V" [17:04:57.054] Got error from ssh: spawn C:\Program Files (x86)\VMware\VMware Workstation\bin\ssh.exe ENOENT [17:04:57.055] Checking ssh with "C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe -V" [17:04:57.056] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe ENOENT [17:04:57.056] Checking ssh with "C:\WINDOWS\system32\ssh.exe -V" [17:04:57.057] Got error from ssh: spawn C:\WINDOWS\system32\ssh.exe ENOENT [17:04:57.057] Checking ssh with "C:\WINDOWS\ssh.exe -V" [17:04:57.058] Got error from ssh: spawn C:\WINDOWS\ssh.exe ENOENT [17:04:57.059] Checking ssh with "C:\WINDOWS\System32\Wbem\ssh.exe -V" [17:04:57.060] Got error from ssh: spawn C:\WINDOWS\System32\Wbem\ssh.exe ENOENT [17:04:57.060] Checking ssh with "C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe -V" [17:04:57.061] Got error from ssh: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT [17:04:57.061] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V" [17:04:57.109] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2 [17:04:57.113] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 61810 "183.175.12.54" sh [17:04:57.114] Generated SSH command: 'type "C:\Users\Lenovo\AppData\Local\Temp\vscode-linux-multi-line-command-183.175.12.54-514770763.sh" | "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 61810 "183.175.12.54" sh' [17:04:57.115] Using connect timeout of 17 seconds [17:04:57.116] Terminal shell path: C:\WINDOWS\System32\cmd.exe [17:04:57.390] > Bad owner or permissions on C:\\Users\\Lenovo/.ssh/config [17:04:57.390] Got some output, clearing connection timeout [17:04:57.406] > 过程试图写入的管道不存在。 [17:04:58.664] "install" terminal command done [17:04:58.665] Install terminal quit with output: 过程试图写入的管道不存在。 [17:04:58.665] Received install output: 过程试图写入的管道不存在。 [17:04:58.666] WARN: $PLATFORM is undefined in installation script output. Errors may be dropped. [17:04:58.666] Failed to parse remote port from server output [17:04:58.666] Resolver error: Error at y.Create (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:744751) at t.handleInstallOutput (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:742832) at t.tryInstall (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:865534) at async c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:824246 at async t.withShowDetailsEvent (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:827501) at async A (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:820760) at async t.resolve (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:824898) at async c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:1113660 [17:04:58.672] ------ [17:04:58.673] No hints found in the recent session. [17:04:59.210] Opening exec server for ssh-remote+183.175.12.54 [17:04:59.228] Initizing new exec server for ssh-remote+183.175.12.54 [17:04:59.228] Using commit id "2901c5ac6db8a986a5666c3af51ff804d05af0d4" and quality "stable" for server [17:04:59.228] Extensions to install: [17:04:59.326] Opening exec server for ssh-remote+183.175.12.54 [17:04:59.329] Install and start server if needed [17:05:03.005] getPlatformForHost was canceled [17:05:03.005] Exec server for ssh-remote+183.175.12.54 failed: Error: 已取消连接 [17:05:03.006] Existing exec server for ssh-remote+183.175.12.54 errored (Error: 已取消连接) [17:05:03.006] Initizing new exec server for ssh-remote+183.175.12.54 [17:05:03.007] Error opening exec server for ssh-remote+183.175.12.54: Error: 已取消连接 [17:05:03.007] No hints found in the recent session. [17:05:03.007] Using commit id "2901c5ac6db8a986a5666c3af51ff804d05af0d4" and quality "stable" for server [17:05:03.007] Extensions to install: [17:05:03.011] Install and start server if needed
最新发布
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值