windows 设置 vscode 免密远程

我们可以使用 vscode ssh 进行远程编辑文件项目。

也可以使用 ssh 密匙 来实现免密登录。

本人在本地windows系统有多个密匙,使用 D:\SPB_Data\.ssh\id_rsa_local 进行本地设备进行登录。

在 vscode ssh 配置文件中添加 IdentityFile 配置

bash 复制代码
Host 本地设备ip
  HostName 192.168.99.132
  User hocker
  IdentityFile "D:\SPB_Data\.ssh\id_rsa_local"

由于文件权限,会报错:

bash 复制代码
[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 中运行

cmd 复制代码
icacls "D:\SPB_Data\.ssh\id_rsa_local"
icacls "D:\SPB_Data\.ssh\id_rsa_local" /inheritance:r /grant:r "%USERNAME%:(R)"

然后就能够免密登录了。

相关推荐
alphaTao6 小时前
LeetCode 每日一题 2025/11/3-2025/11/9
windows·leetcode
习惯就好zz13 小时前
WSL2 安装Ubuntu卡在安装进度0%无响应问题解决
linux·windows·ubuntu·wsl·wsl2
不染尘.16 小时前
2025_11_7_刷题
开发语言·c++·vscode·算法
仰望—星空16 小时前
MiniEngine学习笔记 : CommandListManager
c++·windows·笔记·学习·cg·direct3d
ue星空19 小时前
Windows内核函数使用
windows
这儿有一堆花19 小时前
IDE 开发的一天
ide
swear0119 小时前
VSCODE 插件 rust-analyzer 使用遇到的问题 快捷键查看定义
ide·vscode·rust
业余幻想家20 小时前
Windows10/Windows11家庭版系统关闭自动更新
运维·windows
pengzhuofan20 小时前
IntelliJ IDEA 常用快捷键
java·ide·intellij-idea
麦克马21 小时前
Visual Studio Code 控制台乱码问题
vscode