默认网关不正确,导致sshkey分发错误
在虚拟机上做实验,利用Expec来实现sshkey人分发到多台服务器上,脚本用过多次都没问题,用户也成功添加了;而且脚本返回是OK;如下图
但是,在这些机器上查看是否分发成功;却不存在文件;
[root@lvs-02 swper]# ls /home/sendate/.
./ ../ .bash_logout .bash_profile .bashrc .gnome2/
单个执行,也返回 成功;
expect fenfa_sshkey.exp ~/.ssh/id_dsa.pub 10.0.10.11
直接ssh-copy-id出错了:
ssh-copy-id -i -p 52113 .ssh/id_dsa.pub sendate@10.0.10.11
错误:
ssh-copy-id:/usr/bin/ssh-copy-id: ERROR: No identities found
根据网友的说法,我的错误不应该;
最后实现没办法了,查看了一下路由,因为实验环境里有两张网卡,两个网段;
发现所有机器默认网关都走内网的;内网也是通的;
[root@web-01 swper]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.137.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
0.0.0.0 10.0.10.254 0.0.0.0 UG 0 0 0 eth1
最后把这个内网的默认网关删除,修改网卡配置文件;重新加载网卡后,再发分成功了;而且也不会出现之前等待很久的情况;
[root@web-01 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.137.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
0.0.0.0 192.168.137.1 0.0.0.0 UG 0 0 0 eth0
带外网的机器路由,只有一张网卡的内网机器就不留默认网关了;
由于这次的问题困扰了一个早上,网上也找 不着资料,所以把问题记录一下;