SSH免密登录配置
1 无密钥配置
(1)免密登录原理,如图所示
实现从hadoop01 免密登录至 hadoop02
(2)生成公钥和私钥:
[hadoop@hadoop01 ~]$ ssh-keygen -t rsa
然后敲(三个回车),就会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)
(3)将公钥拷贝到要免密登录的目标机器上
[hadoop@hadoop01 ~]$ ssh-copy-id hadoop02
(4)验证
[hadoop@hadoop01 ~]$ ssh hadoop02
Last login: Tue Oct 27 19:10:02 2020 from gateway
[hadoop@hadoop02 ~]$
2 .ssh文件夹下(~/.ssh)的文件功能解释
known_hosts |
记录ssh访问过计算机的公钥(public key) |
id_rsa |
生成的私钥 |
id_rsa.pub |
生成的公钥 |
authorized_keys |
存放授权过得无密登录服务器公钥 |