Centos7下实现免密码登录

管理员 发布于 3年前   401

Centos7下实现免密码登录


生成密钥

ssh-keygen


authorized_keys:存放远程免密登录的公钥,主要通过这个文件记录多台机器的公钥 

id_rsa : 生成的私钥文件 

id_rsa.pub : 生成的公钥文件 

know_hosts : 已知的主机公钥清单 

如果希望ssh公钥生效需满足至少下面两个条件: 

1) .ssh目录的权限必须是700 

2) .ssh/authorized_keys文件权限必须是600


二、远程免密登录 

1.原理: 

- 客户端向服务器端发出连接请求 

- 服务器端向客户端发出自己的公钥 

- 客户端使用服务器端的公钥加密通讯密钥然后发给服务器端 

- 如果通讯过程被截获,由于窃听者即使获知公钥和经过公钥加密的内容,但不拥有私 钥依然无法解密(RSA算法) 

- 服务器端接收到密文后,用私钥解密,获知通讯密钥 

2.常用以下几种方法: 

2.1通过ssh-copy-id的方式


[root@localhost ~]# ssh-copy-id -i root@worker1

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

root@worker1's password:


Number of key(s) added: 1


Now try logging into the machine, with:   "ssh 'root@worker1'"

and check to make sure that only the key(s) you wanted were added.


请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

该博客于2020-12-7日,后端基于go语言的beego框架开发
前端页面使用Bootstrap可视化布局系统自动生成

是我仿的原来我的TP5框架写的博客,比较粗糙,底下是入口
侯体宗的博客

      订阅博客周刊

文章标签

友情链接

HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群
侯体宗的博客