加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux 批量关闭telnet

发布时间:2020-12-14 00:45:38 所属栏目:Linux 来源:网络整理
导读:shutdown_telnet.sh ckmsce=/home/shutdown_telnet.exp????? username=root?????????????????????????????? [email?protected]???????????????????????? ????????????????????????????????????? omplist=" 192.167.1.1 192.167.1.2 ? ? ? ? ? ? ? ? ?? "????

shutdown_telnet.sh

ckmsce=/home/shutdown_telnet.exp?????
username=root??????????????????????????????
[email?protected]????????????????????????
?????????????????????????????????????
omplist="
192.167.1.1

192.167.1.2 ? ? ? ? ? ? ? ? ??
"????????????????????????????????????
port=23??????????????????????????????
for ompname in $omplist??????????????
do???????????????????????????????????
? $ckmsce $ompname $username $password $port?????
?????????????????????????????????????
done?????????????????????????????????
#-------------------------------------

?

shutdown_telnet.exp

?

#!/usr/bin/expect -f
set date [exec date -d day +‘%Y%m%d‘]
set desthost [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set port [lindex $argv 3]

spawn ssh -D $port [email?protected]$desthost
expect "*assword:*"
send "$passwordr"
expect {
?"*(yes/no)?"
? {
?? send "yesn"
?? expect "*assword:" {send "$passwordn"}
? }
?? "*assword:"
? {
??? send "$passwordn"
? }
? }
expect "*#"
send? "cd /etcr"
expect "*#"
send? "mv securetty_bak securettyr"
expect "*#"
send? "sed -i "s/‘#pts/0‘/‘pts/0‘/g" /etc/securettyr"
expect "*#"
send? "sed -i "s/‘#pts/1‘/‘pts/1‘/g" /etc/securettyr"
expect "*#"
send? "sed -i "s/no/yes/g" /etc/xinetd.d/telnetr"
expect "*#"
send? "sed -i "s/#account??? required???? pam_nologin.so/account??? required???? pam_nologin.so/g" /etc/pam.d/loginr"
expect "*#"
send? "cd /root/r"
expect "*#"
send? "chkconfig? telnet offr"
expect "*#"
send? "service xinetd restsrtr"
sleep 2;
expect "*#"
send? "service xinetd restartr"
sleep 2;
expect "*#"
send "exitr"
interact

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读