#!/bin/sh
_ip_lst="ip_list_n"
_u_lst="user.txt"
for ip in `cat $_ip_lst | grep -v '^#'`;do
for utmp in `cat $_u_lst | grep -vE '^[[:space:]]*$|^#'`;do
user=`echo $utmp | awk -F'|' '{print $1}'`
group=`echo $utmp | awk -F'|' '{print $3}'`
pass=`echo $utmp | awk -F'|' '{print $2}'`
if [ -z "`ssh $ip /usr/bin/id -g $group 2>/dev/null`" ]; then
ssh $ip /usr/sbin/groupadd $group 2>&1
fi
if [ -z "`ssh $ip /usr/bin/id -u $user 2>/dev/null`" ]; then
ssh $ip /usr/sbin/useradd -s /bin/bash -c "User" -g $group $user 2>&1
ssh $ip "echo $pass | passwd --stdin $user"
fi
done
for group in `cat $_u_lst | grep -vE '^[[:space:]]*$|^#' | awk -F'|' '{print $3}' | sort | uniq`;do
ssh $ip -- "echo \"%$group ALL=(ALL) ALL\" >> /etc/sudoers"
done
done
阅读(612) | 评论(0) | 转发(0) |