#!/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

 

相关文章:

  • 2021-11-07
  • 2022-12-23
  • 2021-08-29
  • 2022-03-04
  • 2022-03-05
  • 2021-08-24
  • 2021-11-02
  • 2021-07-13
猜你喜欢
  • 2021-11-13
  • 2021-06-14
  • 2021-05-22
  • 2022-02-26
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
相关资源
相似解决方案