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

[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]

1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!10210454@qq.com
2. 本站不保证所提供所有下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有RB奖励和额外RMB收入!

磊宇堂正在使用的服务器 维护管理由磊宇云服务器提供支持

磊宇堂 » Telnet安装和配置,脚本一键安装!

提供最优质的资源集合

立即查看 了解详情