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 root@$ipaddr expect { "yes/no" { send "yes ";exp_continue } "password" { send "$passwd " } } expect "#" send "touch /root/xuegod1011.txt " send "ls /etc > /root/xuegod1011.txt " send "mkdir /tmp/xuegod1011 " send "exit " 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
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@localhost ~]# uname -r
3.10.0-693.el7.x86_64
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
tail -10 /var/log/messages #查看最后10行
tail -f /var/log/messages #动态查询日志
bash -v test.bash #查看bash是否存在语法错误
bash -x test.bash #查看bash详细的执行过程
ps aux | grep mysql |xargs kill -9