1.生成 SSH 密钥
在终端输入命令
ssh-keygen -t rsa
windows会在此路径下:
C:\Users\Username\.ssh\
linux会在此路径下
~/.ssh/
2.将公钥放置到服务器
将id_rsa.pub 文件内容写入到服务器的 ~/.ssh/authorized_keys 文件中
3.安装VS Code ssh插件
在市场搜索 Remote - SSH 进行安装
4.编辑config文件
将服务器的相关信息写入,就可以通过vscode插件进行连接.
windows: C:\Users\Username\.ssh\config
linux: ~/.ssh/config
根据实际情况填写右侧的实际值
Host mahine_name
HostName 192.168.1.X
User Username
(1)先点击左侧的插件
(2)点击右上角的刷新
(3)点击中间的服务器进行连接