我們可以使用 vscode ssh 進行遠程編輯文件項目。
也可以使用 ssh 密匙 來實現免密登錄。
本人在本地windows系統有多個密匙,使用 D:\SPB_Data\.ssh\id_rsa_local 進行本地設備進行登錄。
在 vscode ssh 配置文件中添加 IdentityFile 配置
Host 本地設備ipHostName 192.168.99.132User hockerIdentityFile "D:\SPB_Data\.ssh\id_rsa_local"
由于文件權限,會報錯:
[14:21:53.194] Got some output, clearing connection timeout
[14:21:53.279] > Bad permissions. Try removing permissions for user: NT AUTHORITY\\Authenticated
> Users (S-1-5-11) on file D:/SPB_Data/.ssh/id_rsa_local.
[14:21:53.285] > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> Permissions for 'D:\\SPB_Data\\.ssh\\id_rsa_local' are too open.
> It is required that your private key files are NOT accessible by others.
> This private key will be ignored.
> Load key "D:\\SPB_Data\\.ssh\\id_rsa_local": bad permissions
> hocker@192.168.99.132's password:
對 D:\SPB_Data.ssh\id_rsa_local 文件進行權限限制, cmd 中運行
icacls "D:\SPB_Data\.ssh\id_rsa_local"
icacls "D:\SPB_Data\.ssh\id_rsa_local" /inheritance:r /grant:r "%USERNAME%:(R)"
然后就能夠免密登錄了。