vscode连接服务器报错Bad permissions.

问题

起因是vscode连接我的云服务器报错

] Resolver error: Error: 已取消连接 at g.Canceled (c:\Users\19733\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:500114) at c:\Users\19733\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:580668 at async t.withShowDetailsEvent (c:\Users\19733\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:584036) at async k (c:\Users\19733\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:577649) at async t.resolve (c:\Users\19733\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:581407) at async c:\Users\19733\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:848023

没有提示输入密码

公钥在服务器配置了(公钥内容添加到远程服务器的 ~/.ssh/authorized_keys 文件)

但是还报错xxxx>ssh xxx Bad permissions. Try removing permissions for user: \\Everyone (S-1-1-0) on file C:/Users/.ssh/config. Bad owner or permissions on C:\\Users\/.ssh/config

解决方案

步骤 1:检查并修改文件权限

你需要确保只有当前用户对 C:\Users\.ssh\config 文件有读写权限。以下是具体步骤:

1.1 打开 PowerShell 或命令提示符

Win + X,选择 Windows PowerShell命令提示符

1.2 修改文件权限

使用 icacls 命令修改文件权限:

icacls C:\Users\.ssh\config /inheritance:r icacls C:\Users\19733\.ssh\config /grant:r %username%:F

解释:

  • icacls C:\Users\19733\.ssh\config /inheritance:r:移除文件的继承权限。
  • icacls C:\Users\19733\.ssh\config /grant:r %username%:F:授予当前用户对文件的完全控制权限。

步骤 2:验证文件权限

你可以使用以下命令验证文件权限是否正确:

icacls C:\Users\.ssh\config

输出应该类似于

C:\Users\.ssh\config NT AUTHORITY\SYSTEM:(I)(F) BUILTIN\Administrators:(I)(F) YOUR_USERNAME:(F)

确保只有 SYSTEMAdministrators 和你的用户名有权限。

步骤 3:重新尝试连接

修改权限后,重新尝试使用 SSH 连接:

ssh xxx

相关推荐
bush410 小时前
使用root账号ssh登录虚拟机ubuntu
运维·ubuntu·ssh
AAA 建材批发王哥(天道酬勤)2 天前
SSH(安全外壳协议)可以基于多种加密算法
运维·安全·ssh
cooldream20092 天前
升级 OpenSSL 的详细步骤(解决 SSH 漏洞的前提)
运维·ssh·openssl
coderWangbuer4 天前
基于SSH的酒店管理系统的设计与实现 (含源码+sql+视频导入教程+文档+PPT)
运维·sql·ssh
金州饿霸5 天前
Mac通过ssh连接工具远程登录服务器( Royal TSX安装及使用)
大数据·运维·ssh
敲代码不忘补水5 天前
使用 SSH 连接 Docker 服务器:IntelliJ IDEA 高效配置与操作指南
服务器·docker·ssh·intellij idea
多恩Stone5 天前
【vs code(cursor) ssh连不上服务器(2)】但是 Terminal 可以连上,问题解决 ✅
服务器·ssh·github
WMYeah7 天前
Goland使用SSH远程Linux进行断点调试 (兼容私有库)
linux·golang·go·ssh·goland
&黄昏的乐师8 天前
多无人机通信(多机通信)+配置ssh服务
linux·服务器·ssh·无人机
zy happy9 天前
Linux之我不会
linux·运维·服务器·ssh·apache