首页 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

为您推荐

linux文件命令

linux文件命令

在 Linux 中,我们可以使用 `with open()` 语句和 `write()` 函数来写入文件。以下是一个简单...
linux的命令

linux的命令

以下是一个简单的 Linux 命令示例,该命令将显示当前日期和时间: “`c #include <st...
linux 命令

linux 命令

由于 Linux 命令是由 C 语言编写的,因此下面是一个简单的用中文编写的 Linux 命令示例,它将输出“Hello...
linux命令tar

linux命令tar

这个问题看起来有些模糊,我不确定您是想了解如何在 Linux 系统中使用 tar 命令,还是如何编写一个名为 tar 的...
linux压缩命令

linux压缩命令

Linux压缩命令:高效管理文件和目录 Linux操作系统提供了一系列强大的压缩命令,使您能够高效地管理文件和目录。无论...

发表回复

返回顶部