VsCode Remote SSH
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*' # This should return the following output:
Name : OpenSSH.Client~~~~0.0.1.0
State : Installed
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent # 表示尚未安裝 OpenSSH.Server 0.0.1.0 版
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Both of these should return the following output:
Path :
Online : True
RestartNeeded : False
補充:如果想要解除安裝則指令如下
Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0SSH 伺服器初始設定
Start-Service sshdSet-Service -Name sshd -StartupType 'Automatic'Get-NetFirewallRule -Name *ssh*New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22Ssh username@servernameusername:使用者帳號servername:可以是這台 OpenSSH Server 設備的 IPThe authenticity of host 'servername (10.00.00.001)' can't be established.
ECDSA key fingerprint is SHA256:(<a large string>).
Are you sure you want to continue connecting (yes/no)?
# 答案必須是「是」或「否」。 回答「是」會將該伺服器新增到本機系統的已知 ssh 主機清單中
# 此時,系統會提示您輸入密碼。 作為安全性預防措施,您的密碼在您輸入時不會顯示
domain\username@SERVERNAME C:\Users\username>
C:\\ProgramData\ssh 底下# Install the OpenSSHUtils module to the server. This will be valuable when deploying user keys.
# 如果運作此命令出現 Powershell 安装 opensshutils 驗證碼簽名無效問題,可以嘗試著升級 PowerShell 版本在執行一次此命令即可
Install-Module -Force OpenSSHUtils -Scope AllUsers
# Start the ssh-agent service to preserve the server keys
Start-Service ssh-agent
# Now start the sshd service
Start-Service sshd
透過命令產生一組公私鑰出來,預設公私鑰會存放於 %USERPROFILE%\.ssh\ 目錄下
部署方式
~.ssh\xxxxxx.pub 移至 server/host 上 (預設通常在 C:\ProgramData\ssh\)administrators_authorized_keys 的檔案 (注意沒有任何副檔名)右鍵 >> 內容 >> 安全性 >> 進階

Authenticated Users 此項目


Authenticated Users 此項目,點擊 移除

Administrators (PCxxx\Administrators) 此項目,點擊 移除
~.ssh\xxxxxx 私鑰到 Client 設備上,接著參考下一段 作為 Client Server 的 windows 10 OpenSSH Client 私鑰設置 的說明%USERPROFILE%\.ssh\ 目錄路徑下即完成 SSH 基本設定Ctrl+Shift+P 開啟快捷命令視窗輸入 remoteRemote-SSH: Open Configuration File 選項config 檔案 Host LabServer #填寫別名例如 LabSever
HostName 172.31.00.00 #主機名稱或是ip位置
User root #登入的使用者名稱
Port #如果有指定的Port號
localhost:4200 來開啟網站的localhost:4200localhost:4200 開啟專案運行的網站了

Get-WindowsCapability -Online | ? Name -like 'OpenSSH*' # This should return the following output:
Name : OpenSSH.Client~~~~0.0.1.0
State : Installed # 表示已安裝 OpenSSH.Client 0.0.1.0 版
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 # Both of these should return the following output:
Path :
Online : True
RestartNeeded : False
ssh-keygen -t rsa -b 4096%USERPROFILE%\.ssh\id_rsa.pubOpenSSH 工具中包含 scp,這是安全的檔案傳輸公用程式,接下來會使用到此命令工具協助進行此工作
ssh user1@domain1@contoso.com mkdir C:\users\user1\.ssh\
scp C:\Users\user1\.ssh\id_ed25519.pub user1@domain1@contoso.com:C:\Users\user1\.ssh\authorized_keys
ssh --% user1@domain1@contoso.com powershell -c $ConfirmPreference = 'None'; Repair-AuthorizedKeyPermission C:\Users\user1\.ssh\authorized_keys