mac上vscode远程linux
Visual Studio Code(简称VSCode)是一个流行的代码编辑器,它支持通过Remote - SSH扩展来远程连接到使用SSH的服务器进行开发,方便各种安全开发、统一环境等场景
env
- mac vs-code
- linux(dev)
1.vscode安装remote-ssh插件
打开vscode -> 进入拓展(Ctrl+Shift+X) -> 下载Remote - SSH
2.ssh配置密钥对
2.1mac
# 密钥对生成
ssh-keygen -t rsa
~/.ssh
id_rsa #私钥
id_rsa.pub #公钥
# ssh配置
~/.ssh/config
Host *
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
Host 20.200
HostName 172.24.20.200
Port 22
User root
2.2linux(remote development)
# 添加公钥
cat <<EOF > ~/.ssh/authorized_keys
id_rsa.pub //复制公钥信息
EOF
# 打开AllowTcpForwarding(dynamic port forward to remote port)
/etc/ssh/sshd_config
AllowTcpForwarding yes
systemctl restart sshd
2.3mac testing ssh
ssh [email protected]
3.打开远程主机
3.1打开主机
remote-explore -> ssh主机 -> 打开
3.2远程下载vscode-server
Downloading VS Code Server… (自动下载要等等)
第一次远程打开需要下载vs-codeserver资源到远程主机~/.vscode-server
[root@euler-200 .vscode-server]# pwd
/root/.vscode-server
[root@euler-200 .vscode-server]# tree -L 2
.
├── cli
│ └── servers
├── code-89de5a8d4d6205e5b11647eb6a74844ca23d2573
├── data
│ ├── CachedProfilesData
│ ├── logs
│ ├── Machine
│ ├── machineid
│ └── User
└── extensions
└── extensions.json
#下载好放到远程主机中(目录结构前后一致)
export COMMIT_ID=89de5a8d4d6205e5b11647eb6a74844ca23d2573
wget -o vscode-server-linux-x64.tar.gz https://update.code.visualstudio.com/commit:${COMMIT_ID}/server-linux-x64/stable
[root@euler-200 .vscode-server]# ll cli/servers/Stable-89de5a8d4d6205e5b11647eb6a74844ca23d2573/server/
total 93M
drwxr-xr-x 4 root root 4.0K Jun 7 14:16 bin
drwxr-xr-x 34 root root 4.0K Jun 7 14:16 extensions
-rw-r--r-- 1 root root 14K Jun 5 03:39 LICENSE
-rwxr-xr-x 1 root root 93M Jun 5 03:40 node
drwxr-xr-x 86 root root 4.0K Jun 7 14:16 node_modules
drwxr-xr-x 3 root root 4.0K Jun 7 14:16 out
-rw-rw-r-- 1 root root 116 Jun 5 03:34 package.json
-rw-rw-r-- 1 root root 50K Jun 5 03:39 product.json
reference
#cn