sshpass -p ‘111’ scp -o “StrictHostKeyChecking=no” -pr id_rsa.pub root@192.168.1.7:/root/.ssh/
完整:
a=nmap -sP 192.168.1.0/24 | grep "^Nmap scan" | egrep -o "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"
passwd=111
for i in $a
do
sshpass -p $passwd ssh-copy-id -i /root/.ssh/id_rsa.pub $i > /dev/null
#echo $passwd
done
:wq