【问题现象】
执行ssh命令时出现Connection reset by 192.168.100.183 port 22
[root@centos35 deploy_183]# sh auto_deploy.sh
+ sshpass -p Root.123 scp -o UserKnownHostsFile=/dev/null -o 'StrictHostKeyChecking no' ./fitstor_api.py 192.168.100.183:/opt/
Warning: Permanently added '192.168.100.183' (ECDSA) to the list of known hosts.
+ sshpass -p Root.123 ssh -o ConnectTimeout=3000 -o UserKnownHostsFile=/dev/null -o 'StrictHostKeyChecking no' root@192.168.100.183 sleep 100
Connection reset by 192.168.100.183 port 22
【解决办法】
删除节点DNS配置,有可能DNS配置不通导致
#192.168.100.183,删除无效的DNS配置
vim /etc/resolv.conf
执行scp导致,连续执行scp和ssh会导致ssh reset,可以增加等待时间 sleep 10
# Create roles
sshpass -p ${Master_PW} scp -o UserKnownHostsFile=/dev/null -o 'StrictHostKeyChecking no' ./add_api.py ${Master_IP}:/opt/
sshpass -p ${Master_PW} ssh -o UserKnownHostsFile=/dev/null -o 'StrictHostKeyChecking no' root@${Master_IP} python /opt/add_api.py