以Mac电脑为例:
- 本地安装vscode remote ssh 插件套装
- 本地通过ssh-keygen生成私钥 和 公钥,然后 ssh-copy-id 命令自动拷贝到远程 ~/.ssh/authorized_key 里, 执行如下命令即可
ssh-keygen -t rsa -f sshkey
ssh-copy-id -i sshkey.pub username@远端Ip
3. 进入配置文件~/.ssh/config,增加本地私钥路径/Users/yumlu/sshkey
vim ~/.ssh/config
Host 远端IP
HostName 远端name
User username
IdentityFile /Users/yumlu/sshkey
免每次输入密码登录方法: