首页 > 其他 > 详细

转载---VisualStudioCode通过SSH远程编辑文件

时间:2018-11-13 12:54:52      阅读:154      评论:0      收藏:0      [点我收藏+]

最近需要长期修改远端服务器上的代码,调试。vim操作又不是很6,想到了远程操作的办法,找到一篇好用的bolg,记录一下。

原文链接:https://blog.csdn.net/qq_38401919/article/details/80728516 

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

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

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

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

 

步骤二:

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

Host myRemoteServerName
    HostName 12.34.567.89
    User root
    ForwardAgent yes
    RemoteForward 52698 127.0.0.1:52698

 

步骤三:

连接远程:

ssh -v myRemoteServerName

 

安装rmate:

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

 

步骤四:

重新登陆远程, 运行

rcode some_file.php

或者

rmate some_file.php

 

文件就会出现在Visual Studio

PS:

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

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

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

以上

转载---VisualStudioCode通过SSH远程编辑文件

原文:https://www.cnblogs.com/hellowooorld/p/9951534.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!