现场服务器较多,密码3个月过期,在到期时需更改密码。 使用expect编写,尝试登陆2次后退出(防止密码错误时账号锁定),超时重试一次。 shell脚本调用并定时执行,登陆成功后执行一条命令,如:hostname、uname等,根据退出状态判断密码是否到期。 0--正常 1--传入参数错...
分类:
系统相关 时间:
2015-06-02 12:54:08
阅读次数:
253
#####批量部署ssh私钥认证#####一、首先安装expect,直接yum即可二、批量部署ssh私钥脚本batch_sshkey.sh==============================================================#!/bin/bashcd/rootcat/root/.ssh/id_rsa.pub>/root/.ssh/authorized_keysforiin`catip.txt`doip=$(e..
分类:
系统相关 时间:
2015-05-31 01:37:29
阅读次数:
344
Above AverageTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 15028Accepted: 7875DescriptionIt is said that 90% of frosh expect to be above av...
分类:
其他好文 时间:
2015-05-22 08:13:34
阅读次数:
95
1 [root@zenghui expect]# cat ssh_dsa.exp 2 #!/usr/bin/expect 3 set ip [lindex $argv 0] 4 set pass [lindex $argv 1] 5 set port [lindex $argv 2] 6 set ....
分类:
系统相关 时间:
2015-05-22 08:12:12
阅读次数:
148
#!/bin/bash
#author:?GaoMing
#date:?2015-05-20
#qq:?530035210
#blog:?http://my.oschina.net/pwd/blog?
#pppoe?定期重新拨号
logdir=/data/log/shell??????????#日志路径
log=$logdir/log....
分类:
其他好文 时间:
2015-05-21 20:01:16
阅读次数:
177
无密钥登录的自动脚本实现:
vim auto_ssh.sh
#!/usr/bin/expect
set timeout 10
set username [lindex $argv 0]
set password [lindex $argv 1]
set hostname [lindex $argv 2]
spawn ssh-copy-id...
分类:
其他好文 时间:
2015-05-21 12:50:37
阅读次数:
115
timeout -1 为永不超时Expect中最关键的四个命令是send,expect,spawn,interact。send:用于向进程发送字符串expect:从进程接收字符串spawn:启动新的进程interact:允许用户交互
分类:
系统相关 时间:
2015-05-19 18:29:21
阅读次数:
157
#!/bin/bash
Local_Dir=‘/tmp/test_huadan‘
Ip=‘192.168.0.221‘
PassWord=‘Lhm0125‘
Des_Dir=‘/tmp/test_huadan‘
List=$(find$Local_Dir-cmin-60)
foriin$List
do
#echo$i
if[-f$i]
then
expect<<EOF#利用expect命令,捕捉Password关键字,然后传入密码,此案例还..
分类:
系统相关 时间:
2015-05-18 21:04:55
阅读次数:
485
第一种方法(expect):
catexpect.sh
#!/usr/bin/expect
#使用第一个参数
setlocal_ip[lindex$argv0]
#后面的也可以用参数[lindex$argvn]
#setpassword[lindex$argv1]
#setpassword2[lindex$argv2]
#setcommand[lindex$argv3]
setlocal_port22
setlocal_userjackchem
setlocal_11..
分类:
其他好文 时间:
2015-05-18 21:01:18
阅读次数:
208