SSH 登录远端后 使用本地 VS Code 编辑远端文件

 2个月前     2  

文章目录

远程 Linux 安装 rmate

wget   https://raw.githubusercontent.com/sclukey/rmate-python/master/bin/rmate  
chmod +x ./rmate
mv ./rmate /usr/local/bin/rmate

vs code 安装 remote vscode 插件

重启 vs code 加载插件。
启动插件: ctrl + shift + P 输入 remote ,点击 Remote: Start Server 。
连接远程系统:powershell 输入:

ssh -R 52698:127.0.0.1:52698 root@hw.bianxh.top

这里 52698 是插件默认端口。如下图:这里也配置了插件自启动: remote vscode 插件自动加载: 文件>首选项>设置 ,搜索 remote:
SSH 登录远端后 使用本地 VS Code 编辑远端文件

之后输入密码 ssh 连接远程 Linux 系统即可。

编辑文件

打开要编辑的文件,例如:

rmate -p 52698 /etc/rc.local

vs code 编辑区就会自动打开该文件。

设置了端口之后,这样子也是可以的:

rmate /etc/rc.local

暂无评论

暂无评论...