1.首先使用xshell5生成密钥对
![img_c66e788fee5c336246dd37d76eb4d9c9.png](https://yqfile.alicdn.com/img_c66e788fee5c336246dd37d76eb4d9c9.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
![img_88f0e415414b142c614b12eebb51e4bf.png](https://yqfile.alicdn.com/img_88f0e415414b142c614b12eebb51e4bf.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
![img_6b9e9f3aa2ecacb64b3e73e701c82b43.png](https://yqfile.alicdn.com/img_6b9e9f3aa2ecacb64b3e73e701c82b43.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
![img_1ea8e65397167998fc83781853ae596a.png](https://yqfile.alicdn.com/img_1ea8e65397167998fc83781853ae596a.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
![img_4f04b21a5d12907eba68adfc9f75c3c3.png](https://yqfile.alicdn.com/img_4f04b21a5d12907eba68adfc9f75c3c3.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
![img_db641adbd154438f2f57cabf6eed648b.png](https://yqfile.alicdn.com/img_db641adbd154438f2f57cabf6eed648b.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
![img_787bd7437e17bcc5054214705bb755c9.png](https://yqfile.alicdn.com/img_787bd7437e17bcc5054214705bb755c9.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
最后点击完成
![img_eb7c976bf082aff4a4d76a9912e7870c.png](https://yqfile.alicdn.com/img_eb7c976bf082aff4a4d76a9912e7870c.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
![img_c8cb013f3405152c129a1c5f7059de2b.png](https://yqfile.alicdn.com/img_c8cb013f3405152c129a1c5f7059de2b.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
2.然后将生成的公钥放到linux服务器上
[root@SecEvery ~]# vim /etc/ssh/sshd_config
AuthorizedKeysFile .ssh/authorized_keys
可以看到默认密钥key放置的文件是.ssh/authorized_keys
![img_319dac94b99c17d83cdedf66034051cb.png](https://yqfile.alicdn.com/img_319dac94b99c17d83cdedf66034051cb.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
[root@SecEvery ~]# pwd
/root
[root@SecEvery ~]# vim .ssh/authorized_keys
![img_261f0871c5ea369e6734c00552c6151c.png](https://yqfile.alicdn.com/img_261f0871c5ea369e6734c00552c6151c.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
然后保存退出,重启ssh服务
[root@SecEvery ~]# service sshd restart
3.使用密钥登录Linux服务器
![img_0867c7de30878be20490be620acfa61e.png](https://yqfile.alicdn.com/img_0867c7de30878be20490be620acfa61e.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
![img_23ecbf965115eeebe4ed51a406d02586.png](https://yqfile.alicdn.com/img_23ecbf965115eeebe4ed51a406d02586.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png
成功登录
![img_1fd333f5f6e7a608d73bd21107cea361.png](https://yqfile.alicdn.com/img_1fd333f5f6e7a608d73bd21107cea361.png?x-oss-process=image/resize,w_1400/format,webp)
图片.png