You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code Remote SSH终端权限异常问题求助

解决方案

1. 确认终端实际用户身份

在VS Code内置终端执行以下命令,核对当前用户及所属组是否和PuTTy终端一致:

whoami
id

若两者输出有差异,说明Remote-SSH连接过程中存在身份切换,需检查扩展连接配置。

2. 验证目录及父目录权限

执行命令查看目标目录及其上级目录的权限设置:

ls -ld /home/[other-user] /home/[other-user]/public_html
  • 若/home/[other-user]权限为drwxr-xr-x(755),其他用户可进入该用户的home目录;结合public_html的drwx---r--(704)权限,其他用户能读取目录内容。要彻底禁止访问,执行以下命令修正权限:
chmod 700 /home/[other-user]
chmod 700 /home/[other-user]/public_html

3. 检查访问控制列表(ACL)

查看目录是否存在额外的ACL规则导致权限绕过:

getfacl /home/[other-user]/public_html

若存在当前用户的额外权限条目,执行命令移除:

setfacl -x u:[your-username] /home/[other-user]/public_html

4. 排查VS Code Remote-SSH配置

  • 打开VS Code设置,搜索remote.SSH.remoteCommand,确认未设置sudo或其他特权命令。
  • 检查本地~/.ssh/config中的服务器配置,确保没有强制切换用户的User字段或特权登录规则。

5. 检查AppArmor规则

Debian默认启用AppArmor,检查VS Code相关的权限规则:

sudo aa-status | grep code

若存在宽松规则,可临时禁用测试:

sudo aa-disable /usr/bin/code

测试后问题解决的话,需调整AppArmor规则以严格限制VS Code的文件访问权限。


内容的提问来源于stack exchange,提问作者Jason Hahn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 12:03:24