Centos7 集群SSH无密码用户免密登录配置
例:配置集群1的A,B,C三台Centos7的test无密码用户免密登录
1,在A机器执行ssh-kengen生成秘钥,一路回车
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | [root@lms lms] # su - test [ test @ test ~] # ssh-keygen Generating public /private rsa key pair. Enter file in which to save the key ( /root/ . ssh /id_rsa ): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/ . ssh /id_rsa . Your public key has been saved in /root/ . ssh /id_rsa .pub. The key fingerprint is: SHA256:0jykURKZQMKvbEhlncm6Kef2ZH8mYwRUlYsdj1nzjZ0 root@lms The key's randomart image is: +---[RSA 2048]----+ | ...=.*=o.. | | .+ *oo o o | | o.o . + B o + .| | . ... B = . o E | |.o .o + S | |..++ o . | | .+ o. | | oo .+ o | | . ....= | +----[SHA256]-----+ [ test @ test ~] # |
2,在该用户的家目录会生成一个.ssh目录,进入该目录,拷贝一份公钥(id_rsa.pub),并命名为 authorized_keys
1 2 3 4 5 6 7 8 9 10 11 | [ test @ test ~] # cd .ssh/ [ test @ test . ssh ] # pwd /home/test/ . ssh [ test @ test . ssh ] # ll 总用量 12 -rw-------. 1 test root 1675 6月 29 17:01 id_rsa -rw-r--r--. 1 test root 390 6月 29 17:01 id_rsa.pub -rw-r--r--. 1 test root 1042 6月 6 10:08 known_hosts [ test @ test . ssh ] # [ test @ test . ssh ] # cp id_rsa.pub authorized_keys [ test @ test . ssh ] # |
3,在B,C机器的test用户下执行ssh-keygen
4,将 id_rsa,id_rsa.pub,authorized_keys拷贝至B,C机器的/home/test/.ssh下即可(使用root用户拷贝)
1 | [root@ test . ssh ] # scp authorized_keys id_rsa id_rsa.pub root@10.10.10.1:/home/test/.ssh/ |
5,测试,切换test用户:su - hdfs,执行ssh test@10.10.10.2
1 2 3 | [root@ test ~] # su - test [ test @ test ~] # [ test @ test ~] # ssh test@10.10.10.1 |
本文作者:香菜哥哥
本文链接:https://www.cnblogs.com/yizhipanghu/p/17514738.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步