linux - 无法以用户身份启动 VS Code 远程桌面,但可以通过终端以用户身份登录
问题描述
我遇到了一个问题,当我使用我的用户名时,我无法在 VS Code 中启动远程桌面会话,但我可以使用 root。在通过 zsh 终端的正常 ssh 会话中,我可以正常登录 root 和用户名。
我的笔记本电脑上的 ~/.ssh/config 看起来像这样
Host greenpatch.dev
HostName greenpatch.dev
User jake
IdentityFile ~/.ssh/my-awesome-key
当我尝试在 VS 代码中使用远程桌面进行 ssh-ing 时,它说它无法连接。我在终端中看到的输出如下:
### shows the normal ubuntu success screen, ssh key worked and all, then
ready: 4e672f435229
Linux 5.4.0-65-generic #73-Ubuntu SMP Mon Jan 18 17:25:17 UTC 2021
4e672f435229: running
bash: line 1: syntax error near unexpected token `then'
bash: line 1: `]; then'
-sh: 4: function: not found
-sh: 69: [[: not found
-sh: 90: [[: not found
-sh: 149: Syntax error: "(" unexpected (expecting "then")
我的临时工作是将我的配置更改为以 root 身份登录:
Host greenpatch.dev
HostName greenpatch.dev
User root
IdentityFile ~/.ssh/my-awesome-key
然后我su - jake
。根在 VS Code 远程桌面中工作。
奇怪的是,我还可以ssh jake@greenpatch.dev
。它只发生在 VS Code 远程桌面中。
- 我已检查我的授权密钥
/home/jake/.ssh/authorized_keys
是否已更新 - 我重新启动了我的笔记本电脑,认为存在缓存问题
- 我停止并重新启动服务器
解决方案
我找到了!我的用户 jake 是通过 shell 而不是 bash 登录的。jake
当我运行命令时,我通过终端 ssh 进入:
chsh -s /bin/bash
这将我的默认 shell 设置为 bash 而不是 sh。我在 VS Code 中启动了远程桌面会话,它运行良好。我猜 VS Code 不会为你切换到 bash,所以发生错误是因为 VS Code 扩展试图在 sh.conf 中运行 bash 脚本。
推荐阅读
- firebase - 为什么在 firebase 连接期间 int map 操作出现错误?as String' 不是 'int' 类型的子类型
- c - 是否有一个 C 宏可以替换文件中不同长度的函数/字符串(正则表达式)?
- web - 建模关系数据库表以跟踪阶段的状态和阶段内的任务
- reactjs - 如何用 Next js 听屏幕位置?
- python - 用鼠标悬停在上面时,智能感知 vscode 不显示参数或文档
- python - Discord.py:检查用户是否具有列表中的角色 ID 不起作用
- rich-text-editor - 在光标位置插入文本 niceEdit
- c# - 关联您的 Microsoft 帐户。电子邮件输入。一次又一次
- sql - SQL 只允许其他列匹配的外键
- python-3.x - 如何在 Python Swipl Prolog 实现中从查询结果中删除 Atom 和 Functor 关键字?