标签:复制 密码 node cas 免密 val color ssh add
背景: 有时候我们在两个主机之间复制文件的时候,提示输入密码,很不方便,那如何免密码复制呢?,就是使用通过linux公钥和秘钥,建立双机信任关系。
1. 生成秘钥,并添加信任
我的环境中node1的ip是192.168.168.201,node2的ip是192.168.168.202.
[root@node1 ~]# ssh-keygen -t rsa -P ‘‘ -f ~/.ssh/id_rsa #生成rsa
[root@node1 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.168.202 #复制公钥
[root@node2 ~]# ssh-keygen -t rsa -P ‘‘ -f ~/.ssh/id_rsa #生成rsa
[root@node2 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.168.201 #复制公钥
2.测试
[root@node1 ~]# ssh 192.168.168.202 ‘ip addr show dev eth0 ‘ 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:50:56:3f:42:13 brd ff:ff:ff:ff:ff:ff inet 192.168.168.202/24 brd 192.168.168.255 scope global eth0 inet6 fe80::250:56ff:fe3f:4213/64 scope link valid_lft forever preferred_lft forever [root@node2 ~]# ssh 192.168.168.201 ‘ip addr show dev eth0‘ 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:c9:20:88 brd ff:ff:ff:ff:ff:ff inet 192.168.168.201/24 brd 192.168.168.255 scope global eth0 inet 192.168.168.200/24 brd 192.168.168.255 scope global secondary eth0 inet6 fe80::20c:29ff:fec9:2088/64 scope link valid_lft forever preferred_lft forever
标签:复制 密码 node cas 免密 val color ssh add
原文地址:http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_023_sshgenkey.html