Telnet安装和配置,脚本一键安装!-linux安全运维_跨零代码

跨零代码为大家提供高品质的运维解决方案,请大家多多来访,跨零不胜感激,在此谢过。

[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<=3;i++))do echo “pts/$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<<EOF
test
test
EOF
[ $? -eq 0 ]&& echo “User Creating Successfully…..”
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]


//下面这个css和插件后台设置的主题有关系,如果需要换样式,则需要修改以下CSS名称

从零到一,创造未来!跨零代码综合IT问题解决服务站,欢迎你的到来。运维教程 只为你绽放。

本文固定链接: http://kua0.com/2019/02/03/telnet安装和配置,脚本一键安装!-linux安全运维_跨零代/

为您推荐

发表评论

电子邮件地址不会被公开。 必填项已用*标注