
ssh-keygen之后一路回车,默认不设密码,默认目录为 ~/.ssh
cat id_rsa.pub >> authorized_keys
sudo chmod 600 authorized_keys
sudo chmod 700 ~/.sshid_rsa.pub 替换为你的公钥路径即可,如果是在本地生成需上传至服务器端。authorized_keys 后面追加,而 Linux 公钥验证检测 authorized_keys 文件中的公钥1、打开SSH配置文件
sudo vim /etc/ssh/sshd_config2、查看确认下面两项配置
RSAAuthentication yes
PubkeyAuthentication yesPasswordAuthentication no3、重启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"Author: Frytea
Title: Linux部署私钥实现免密登录
Link: https://cloud.tencent.com/developer/article/1666278
Copyright: This work by TL-Song is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.