vscode遠程Windows主機開發

基本要求

  1. 參考資料:
    https://docs.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_overview
    https://code.visualstudio.com/docs/remote/ssh
  2. 要求:Windows10 1803或以上版本

安裝步驟

  1. 使用 PowerShell 安裝 OpenSSH
# 檢查是否有OpenSSH功能
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
  1. 啓動並配置 OpenSSH 服務器
# Start the sshd service
Start-Service sshd

# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'

# Confirm the firewall rule is configured. It should be created automatically by setup.
Get-NetFirewallRule -Name *ssh*

# There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled
# If the firewall does not exist, create one
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
  1. 爲 Windows 中的 OpenSSH 配置默認 shell
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force

登錄成功

使用vscode遠程

配置:

Host pywin10
  HostName pywin10
  User admin

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章