本地环境:MacOS
1、Vscode 安装 Remote Development 插件
2、本地主机和远端的主机配置免密登录
将本地.ssh/id_rsa.pub文件中的内容追加到远端主机的.ssh/authorized_keys文件中(假如远端的账户为test,本地账户无限制)
3、配置远端主机的连接
配置内容如
Host *
ForwardAgent yes
ServerAliveInterval 3
ServerAliveCountMax 20
TCPKeepAlive no
# Make connect faster
ControlMaster auto
ControlPath ~/.ssh/%h-%p