VSCode 远程开发
For macOS
brew install xquartz
之后每次都需要先启动 xquartz
安装 VSCode
安装插件
Remote Development
Remote X11
上传密钥
sudo vim ~/.ssh/authorized_keys
修改 SSH 配置文件
Remote 端
ssh <remote-user-name>@<remote-ip-addr> -p <remote-ssh-port>
sudo vim /etc/ssh/sshd_config
修改为
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
PasswordAuthentication no
AllowAgentForwarding yes
AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
运行
sudo vim ~/.ssh/authorized_keys
修改为
将公钥 .pub 文件中内容复制进来并保存
运行
systemctl restart sshd.service
exit
本地端
sudo vim /etc/ssh/ssh_config
修改为
ForwardX11 yes
ForwardX11Trusted yes
运行
systemctl restart ssh.service
将私钥保存为
~/.ssh/id_rsa
修改 VSCode 配置文件
单击左下角的绿色 Remote 按钮,选择
Remote-SSH:Open Configuration File...
选择第一个,修改为
Host <create-name-for-this-connection>
HostName <remote-ip-addr>
User <remote-user-name>
Port <remote-ssh-port>
IdentityFile <ssh-id-rsa-file-path>
同步插件
连接 Remote 端,并同步所有下载的插件