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

相关推荐
埃博拉酱3 天前
VS Code Remote SSH 连接 Windows 服务器卡在"下载 VS Code 服务器":prcdn DNS 解析失败的诊断与 BITS 断点续传
windows·ssh·visual studio code
zhangfeng11334 天前
趋动云 如何ssh登录 服务区 项目server
运维·人工智能·ssh
txzz88884 天前
CentOS-Stream-10 Secure Shell服务器
linux·centos·ssh·secure shell·ssh服务器
文静小土豆5 天前
CentOS 7 OpenSSH 10.2p1 升级全攻略(含离线安装与回退方案)
linux·运维·centos·ssh
最最菜的菜鸟5 天前
本地环境通过 SSH 协议访问 GitHub 上的仓库时,SSH 公钥认证失败,配置 Git SSH 密钥
git·ssh·github
ol木子李lo7 天前
Linux 命令备忘录
linux·运维·服务器·windows·编辑器·ssh·bash
m0_738120727 天前
渗透测试——Momentum靶机渗透提取详细教程(XSS漏洞解密Cookie,SS获取信息,Redis服务利用)
前端·redis·安全·web安全·ssh·php·xss
小哈里8 天前
【工具】Linux远程开发核心工具,Git命令缩写与SSH常用命令
linux·git·ssh·工具·远程开发
推理幻觉8 天前
ssh远程连接错误
运维·ssh
能源革命9 天前
Ubuntu24.04修改ssh默认端口
linux·服务器·ssh