-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractive.sh
More file actions
28 lines (27 loc) · 932 Bytes
/
Copy pathinteractive.sh
File metadata and controls
28 lines (27 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
Host='/root/1.txt'
##1.txt里边放的IP地址
for i in $(cat $Host)
do
expect -c "
spawn ssh root@$i
expect {
"\(yes/no\)\?" {send \"yes \r\"; exp_continue}
\"password:\" {send \"ZMe%Rha4Gi\r\"; exp_continue}
\"root@*\" {send \"useradd sl_zq && echo 'uMBnRn*#Zp' | passwd --stdin sl_zq &> /dev/null && echo 'sl_zq ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers\r exit\r\" ; exp_continue}
}
"
done
#'#!/bin/bash'
#Host='/root/1.txt'
#for i in $(cat $Host)
#do
# expect -c "
# spawn ssh root@$i
# expect {
# \"password:\" {send \"ZMe%Rha4Gi\r\"; exp_continue}
# \"root@*\" {send \"chage -M 9999 oma\r exit\r\"; exp_continue}
# }
# "
#echo "----------------------------------------------------------------------------------------------------"$i""
#done