remote SSH在第一次啓動時會讓用戶選擇配置文件的存儲位置,這裏我選擇了默認位置:C:\Uses\yourUsername\.ssh\config
。
當我們想使用SSH私鑰登錄服務器時,只需在上述文件裏添加一條:IdentityFile /path/to/yourPrivateKey
。
而該私鑰可自己生成或複用其他工具生成的,最後config
文件內容如下:
Host name-of-ssh-host-here
User your-user-name-on-host
HostName host-fqdn-or-ip-goes-here
IdentityFile ~/.ssh/id_rsa-remote-ssh
關聯官方文檔:
https://code.visualstudio.com/docs/remote/troubleshooting#_configuring-key-based-authentication