首页 Linux网维 Telnet安装和配置,脚本一键安装!

Telnet安装和配置,脚本一键安装!

[cce]#!/bin/bash#install the telnet service #defaultly add a user to test: #default_user: …

[cce]#!/bin/bash#install the telnet service #defaultly add a user to test: #default_user: test default_passwd: test

set +H config_file=/etc/xinetd.d/telnet read -t 10 -p “installing now ?(y|n):” AN case $AN in n|N|no)

:;; *) echo “start installing…..”;sleep 2 yum install -y telnet-server [ $? -ne 0 ]&& (echo “install fail…..”;exit 1)

echo “install secussfully….”;; esac echo “Start to config…”;sleep 3 sed -i /disable/s/yes/no/ $config_file

if [ $? -eq 0 ];then sed -i /disable/d $config_file sed -i /{/a\\tdisable=no $config_file read -t 20 -p “limit the accessing ip{y|n} ?” AN

fi case $AN in yes|y|Y) while : do read -p “import the ip or network{eg 10.1.1.1 or 10.1.1.0/24}:” IP_NET

sed -i “/{/a\no_access=$IP_NET” $config_file [ $? -eq 0 ]&&echo “Successfully……” echo -e “\n” read -t 10 -p “Go on ??(y|n):” answer

case $answer in yes|y|Y) continue;; *) break;; esac done;; *) echo -e “\n”;; esac read -t 20 -p “set the only ip or net to access?(y|n):” AN

case $AN in yes|y|Y) while : do read -p “import the ip or network{eg 10.1.1.1 or 10.1.1.0/24}:” IP_NET

sed -i “/{/a\only_from=$IP_NET” $config_file [ $? -eq 0 ]&&echo “Successfully……” echo -e “\n” read -t 10 -p “Go on ??(y|n):” answer

case $answer in yes|y|Y) continue;; *) break;; esac done;; *) echo -e “\n”;; esac read -t 20 -p “if you need to change the port of telnet service?(y|n):” AN

case $AN in Y|y|yes) read -p “Import the port you want to change to:” PORT echo “wait,changing…..”;sleep 2

sed -i “/^telnet/s/[0-9][0-9]*/$PORT/” /etc/services ([ $? -ne 0 ]&& echo “sorry the changing has failed!!! the port is still 22,you can change by yourself!!”)|| \

echo “Changing successfully !!! the port of telnet is $PORT now!! you had batter remember this!!!”;;

*) echo -e “\n”;; esac echo “The firewall may stop the telnet service,stop them or import a rule to allow?”

select var in “Stop_firewall” “Import_A_rule” ;do break done echo “now do as your choice :$var”;sleep 3

case $var in “Stop_firewall”) WORD=`service iptables status|grep -o stopped` if [ -n $WORD ];then echo “The firewall has been stopped….”

else service iptables stop ([ $? -ne 0 ]&&echo “Failed…!! please do that by yourself….”)|| \ (echo “Successfully……”;sleep 1)

fi;; *) service iptables restart >/dev/null 2>&1 iptables -I INPUT 1 -p tcp –dport 22 -j ACCEPT ([ $? -ne 0 ]&&echo “Failed…!! please do that by yourself….”;sleep 1)|| \

echo “Successfully……”;; esac read -t 10 -p “If you want to let the root user to login?(y|n):” AN

case $AN in y|Y|yes) for((i=0;i>/etc/securetty;done [ $? -eq 0 ]&&echo ” Sucessfully…..”;sleep 2;;

*) :;; esac chkconfig –add telnet > /dev/null 2>&1 chkconfig –level 35 telnet on > /dev/null 2>&1 echo “Creating the user:test and the password is :test”| grep test –color=yes ;sleep 2

useradd test passwd test>/dev/null 2>&1<

read -t 6 -p “Start the sevice ?(y|n):” AN case $AN in N|n|no) :;; *) echo -e “\n” service xinetd start

[ $? -eq 0 ]&&echo “Successfully starting….”;sleep 3;; esac echo -e “now exiting….”;sleep 2[/cce]

免责声明:文章内容不代表本站立场,本站不对其内容的真实性、完整性、准确性给予任何担保、暗示和承诺,仅供读者参考,文章版权归原作者所有。如本文内容影响到您的合法权益(内容、图片等),请及时联系本站,我们会及时删除处理。

作者: 3182235786a

为您推荐

CentOS系统升级内核版本教程,centos内核版本升级

CentOS系统升级内核版本教程,centos内核版本升级

CentOS 系统升级系统内核版本  1、显示CentOS 系统内核版本:             [root@demo...
Linux下对 Nginx SSL 的性能进行调整

Linux下对 Nginx SSL 的性能进行调整

初始化服务器   这个web服务器运行在一个EC2 t1.micro 环境.我选择 Nginx + PHP5-FPM 来...
Linux Shell经典实例解析:Oracle启动脚本

Linux Shell经典实例解析:Oracle启动脚本

Oracle的启动脚本从功能上讲主要分为两个部分,第一部分是初始化各种环境变量,以确认当前Oracle服务器的版本,从而...
centOS6.4 64位下安装nfs文件共享系统

centOS6.4 64位下安装nfs文件共享系统

不知道谁装的服务器,默认自带,以下内容摘自互联网,配置部分按教程执行成功 一、环境介绍:   服务器:centos 19...
Linux下的Samba安装配置

Linux下的Samba安装配置

1 Samba 简介 Samba(SMB是其缩写) 是一个网络服务器,用于Linux和Windows共享文件之用;Sam...

发表回复

返回顶部