#!/bin/bash # if exist id_rsa if [ ! -f ~/.ssh/id_rsa ];then ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa else echo "id_rsa has created ..." fi # distribute to hosts in file nehosts while read line do # ignore comment or null line if [[ "$line" =~ ^[^[:space:]]*# || -z "$line" ]]; then continue fi ip=`echo $line | cut -d " " -f 1` user=`echo $line | cut -d " " -f 2` passwd=`echo $line | cut -d " " -f 3` # !!! to remove ~/.ssh, all old authorized key will be lost expect <