非交互免密

sshpass -p ‘111’ scp -o “StrictHostKeyChecking=no” -pr id_rsa.pub [email protected]:/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

你可能感兴趣的:(非交互免密)