Linux配置各个节点之间ssh免登录

这里以node01、node02两台机举离说明,node01、node02为主机名(前提已安装好ssh服务)
1、在node01生成公钥,输入以下:ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa ,按回

[root@node01 .ssh]#  ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
Generating public/private rsa key pair.
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:
72:ea:01:e5:d6:93:eb:f7:b3:77:78:a0:f6:4c:62:03 root@node03
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|      .          |
|     o . .       |
|    . + S E      |
|     o + o .  .  |
|      o .   +..o |
|     . o  ..+=o o|
|      . .. oo=oo |
+-----------------+

进入cd /.ssh下,ls 看到 生成了authorized_keys、id_rsa、id_rsa.pub三个文件

[root@node01 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts

2、把node01公钥copy到node02上,输入:ssh-copy-id node02,按回车

[root@node01 .ssh]# ssh-copy-id node02
The authenticity of host 'node01 (192.168.1.71)' can't be established.
RSA key fingerprint is 2c:ba:d0:09:35:a1:dc:b2:7c:67:c4:72:c1:77:c0:80.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node03,192.168.1.71' (RSA) to the list of known hosts.
root@node02's password: 
Now try logging into the machine, with "ssh 'node01'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

首次操作输入密码,输入密码后即把id_rsa.pub写入到node02的对应路径下authorized_keys中
3、免密码登录测试,在node01上输入命令 ssh node02 

[root@node01 .ssh]# ssh node02
Last login: Sat Sep 16 03:31:06 2017 from node01
[root@node02 ~]# 

可以看到直接进入到node02了,node02想免密码登录node01同理,重复以上操作即可。
注意(配置集群时本机也要进行ssh-copy-id node01操作,把id_rsa.pub复制到本机的authorized_keys中)

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值