#!/bin/bash username=$1 # 创建用户 ansible all -m shell -a "useradd $username" # 设置密码 ansible all -m shell -a "echo '123456'|passwd --stdin $username" # 推送共钥 sh pull_key.sh $username # 添加sudo权限 ansible all -m shell -a "echo '$username ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
#!/bin/bash username=$1 # fenfa key file for ip in `cat ip.txt` do echo "===== fenfa key to host $ip =====" sshpass -p'123456 ssh-copy-id -i /home/${username}/.ssh/id_rsa.pub "-o StrictHostkeyChecking=no" ${username}@$ip echo "============= fenfa end ==================" echo "" done