vscode连接远程服务器日志显示Bad permissions. Try removing permissions for user: NT AUTHORITY\\Authenticated Users 和 Permissions for 'D:\\路径\\xxx\\xxx\\key' are too open.
部分核心日志信息
[19:44:31.905] > Bad permissions. Try removing permissions for user: BUILTIN\\Users (S-1-5-32-545 > ) on file D:/路径/xxx/your_key. [19:44:31.937] > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ > @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ > Permissions for 'D:\\路径\\xxx\\your_key' are too open. > It is required that your private key files are NOT accessible by others.
原因
私钥文件权限太开放,SSH 拒绝使用它。
Windows 上虽然不像 Linux 那样严格,但 OpenSSH for Windows 仍然要求:
Windows 上虽然不像 Linux 那样严格,但 OpenSSH for Windows 仍然要求:
只有当前用户有读取权限,其他用户(包括“Authenticated Users”)必须被移除。
解决
- 以 管理员身份 打开 PowerShell / CMD
-
依次执行(路径换成你的):
1. 清掉所有继承权 icacls D:\your_path\key /inheritance:r 2. 移除所有现有 ACE(只剩空列表) icacls D:\your_path\key /remove *S-1-5-32-545 *S-1-5-11 SYSTEM Everyone 3. 输入 whoami 查看“电脑名\用户名” 4. 把显示出来的名字放入替换以下字段: icacls D:\your_path\key /grant:r "whoami输出的整串:(R)" 例: icacls D:\your_path\key /grant:r "DESKTOP-ABCD\zhangsan:(R)" 5. 验证结果: icacls D:\your_path\key 合格输出应 只有一行: qa_key 你的电脑名\你的用户名:(R) 不能出现 BUILTIN\Users、Authenticated Users、SYSTEM、Everyone 等任何别的 SID。vscode中的ssh的config中的代码
Host A100 HostName 180.180.180.180 User your_username Port 12345 IdentityFile D:\your_path\your_key

浙公网安备 33010602011771号