(一) remote-ssh 插件
- 安装插件 remote-ssh
- 安装成功后点击左边栏的图标
- 点击小齿轮配置
Host <name>
HostName 192.168.0.xxx
User linuxUserName
IdentityFile C:\Users\...\.ssh\id_rsa
# 这个路径放私钥,随便放在那里都可以
(二) Linux 密钥登录
ssh-keygen -C mykey
- cd ~/.ssh 可以看到生成的密钥
- 在 .ssh 目录下,制作公钥
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
chmod 700 ~/.ssh
/etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
root 用户能否通过 SSH 登录:
PermitRootLogin yes
当完成全部设置,以密钥方式登录成功后,可以禁用密码登录:
PasswordAuthentication no
最后,重启 SSH 服务:
service sshd restart
或者
sudo service sshd restart
- 最后把私钥下载到本机,配置 vscode --> remote-ssh 即可
插件