expect免互交
yum -y install expect cat ip_pass.txt #这里写上要执行的IP地址和root用户密码 192.168.1.63 123456 192.168.1.63 123456 192.168.1.63 123456 cat ssh2.exp #编写要执行的操作 #!/usr/bin/expect set ipaddr [lindex $argv 0] set passwd [lindex $argv 1] set timeout 30 spawn ssh [email protected]$ipaddr expect { "yes/no" { send "yes\r";exp_continue } "password" { send "$passwd\r" } } expect "#" send "touch /root/xuegod1011.txt\r" send "ls /etc > /root/xuegod1011.txt\r" send "mkdir /tmp/xuegod1011\r" send "exit\r" expect eof cat login.sh #开始执行 #!/bin/bash echo for ip in `awk ‘{print $1}‘ /root/ip_pass.txt` do pass=`grep $ip /root/ip_pass.txt|awk ‘{print $2}‘` expect /root/ssh.exp $ip $pass done
统计/etc/ssh/sshd_config文件中除去空行和#号开头的行的行数
egrep -v "^$|^#" /etc/ssh/sshd_config
sed -i ‘s/root/xuegod/‘ /etc/passwd
sed -i ‘s/IPADDR=192.168.1.63/IPADDR=192.168.1.65/‘ /etc/sysconfig/network-scripts/ifcfg-ens33
cut -f1 -d ":" /etc/passwd
date | md5sum | cut -c1-6
bash -v test.bash #查看bash是否存在语法错误bash -x test.bash #查看bash详细的执行过程