ssh-keygen
之后一路回车,默认不设密码,默认目录为 ~/.ssh
cat id_rsa.pub >> authorized_keys
sudo chmod 600 authorized_keys
sudo chmod 700 ~/.ssh
1、打开SSH配置文件
sudo vim /etc/ssh/sshd_config
2、查看确认下面两项配置
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
3、重启SSH
sudo service sshd restart
如果客户端为windows,您的私钥应存在于 C:\Users\your name\.ssh\ 目录下,或是在登陆时指定私钥地址:
$ ssh -i id_rsa remote-username@remote-ip
如果是使用 VS Code 远程连接则需要在配置中指定私钥地址:
Host Ali-Dev-Test
HostName *.*.*.*
User root
IdentityFile "H:\我的云端硬盘\Security\ssh-key\aliyun-frytea-edu-t5.pem"