Centos 6.8 公钥登录

# lsb_release -a
LSB Version:	:base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID:	CentOS
Description:	CentOS release 6.8 (Final)
Release:	6.8
Codename:	Final

Centos 6.8 公钥登录

第一步:开启公钥登录

修改文件

# vim /etc/ssh/sshd_config

开启公钥登录

#开启秘钥登录
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

重启sshd

service sshd restart

第二步:增加本地公钥文件

修改文件

vim ~/.ssh/authorized_keys 

增加自己本地的公钥文件内容

# cat ~/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDU3UxwVJVTqY80s9HhGrBue3PIbsvWuIkXxIokPLN8C6mSUW/PeJQ73jjp1ZXEEygePXkxAou7JsPBItHQ5C7U1Zg6rAt3x7JTccNjvoVIRRbpxLY4AK/qlr1nEHtLxGEfCTtZ4pVrtEyLXQDGYIS6lexvA96z9Z19YfZLRRkzbPp6Jud8kBG+j3hLAlfXMkB/+HJ6HFOQ7Sa5DUoZn98on0LvZPdThxwxBpLcNqjIZ3tiTUobnY1EKbi/8kcq9tS8vLoPFdsEQM4F3pe9P6cXQGaHy73z06/tWGfsVlGomJFSOrvNvtPXd/SsRRLrUMlE8yM7zQaoZULNG7KEVyb jiqing@JQ-Mac

第三步:尝试公钥登录

尝试公钥登录

$ ssh root@xxx
Last login: Wed Dec  4 11:28:52 2019 from 218.93.209.11

Welcome to Alibaba Cloud Elastic Compute Service !

第四步:禁止密码登录

修改文件

# vim /etc/ssh/sshd_config

去掉密码登录

PasswordAuthentication no # 禁止密码登录

重启sshd

service sshd restart
posted @ 2019-12-04 11:43  TBHacker  阅读(408)  评论(0编辑  收藏  举报