VisualStudioCode通过SSH远程编辑文件


翻译修改自:https://codepen.io/ginfuru/post/remote-editing-files-with-ssh

在远程服务器上编写文件是一件很糟糕的事情,vim和其他终端编辑器,让速度和熟练度大打折扣,一整天使用vimFTP客户端并不是一件舒心的事情。

所以,如果你已经知道 SSH 是什么以及涉及到什么,你可以完全访问你的服务器,你就无需害怕终端。

现在我们通过使用Visual Studio代码通过 SSH 远程编辑文件

步骤一:
1
安装扩展 `remote-vscode`
步骤二:

添加 RemoteForward 52698 127.0.0.1:52698~/.ssh/config:

1
2
3
4
5
Host myRemoteServerName
HostName 12.34.567.89
User root
ForwardAgent yes
RemoteForward 52698 127.0.0.1:52698
步骤三:

连接远程:

1
大专栏  VisualStudioCode通过SSH远程编辑文件e">
ssh -v myRemoteServerName

安装rmate:

1
wget -O /usr/local/bin/rcode https://raw.github.com/aurora/rmate/master/rmate &&chmod a+x /usr/local/bin/rcode
步骤四:

重新登陆远程, 运行

1
2
3
4
5
rcode some_file.php

或者

rmate some_file.php

文件就会出现在Visual Studio

PS:

我在远程添加别名 .bashrc –> alias code='rcode' 这样我的本地和远程就可以用相同的命令从终端打开Visual Studio

如果报错 “no such file or directory” , 你需要编辑PATH:

1
echo "export PATH="$PATH:/usr/local/bin"" >> /etc/profile

以上


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM