1.下载vscode remote ssh插件
2.安装ssh并生成私钥
windows可通过git来安装ssh
从git官网安装git客户端,一路下一步之后,鼠标右键,点开git bash
配置你的git用户名和邮箱
git config --global user.name “yuzhenrong“
git config --global user.email “[email protected]”
生成私钥
ssh-keygen -t rsa -C “[email protected]”
连续三次enter键之后,操作成功,会提示秘钥生成位置,即ssh目录,如下
把密钥同步到服务器
scp C:\Users\yu137.ssh\id_rsa.pub [email protected]:~/tmp.pub
ssh [email protected] “mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub”
3.配置remote ssh
新建config文件,并在文件里面添加用户名和远程服务器ip地址