VisualStudioCode通过SSH远程编辑文件


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

在远程服务器上编写文件是一件很糟糕的事情,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

以上


文章作者: Qliang
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Qliang !
评论
 上一篇
centos搭建SoftEtherVpn centos搭建SoftEtherVpn
搭建流程一、选择 vpn 服务我选用的是softether 选择的版本为 linux 版本(只有英文版)SoftEther VPN Server 因为用的是 mac,在本地机上下载SoftEther VPN Server Manager
2018-06-20
下一篇 
centos重建服务器 centos重建服务器
-、云服务器重建系统注意点centos 下 ssh 登录的目录权限严格限制 地址:https://wiki.centos.org/HowTos/Network/SecuringSSH 二、搭建docker及docker-compose安
2018-06-18
  目录