千万个美丽的未来,抵不上一个温暖的现在,每一个真实的现在,都是我们曾经幻想的未来!
Apr
10
一、使用YUM安装telnet:
yum install telnet telnet-server -y
安装之后修改/etc/xinetd.d/telnet文件,把disable那一行改为disable = no,[注:如果是CentOS7请忽略这一步]
vi /etc/xinetd.d/telnet
# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}
修改完之后,保存并退出
#CentOS上启动telnet服务并设置开机启动
service xinetd start
chkconfig telnet on
chkconfig xinetd on
#CentOS 7上:
systemctl start telnet.socket
systemctl enable telnet.socket
#CentOS默认防火墙没有开放23端口,所以我们要根据需要允许23端口
vi /etc/sysconfig/iptables
加入一条“-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT”
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
保存并退出,然后重新启动iptables服务
service iptables restart
也可以输入以下命令:
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT
立即生效,然后输入 service iptables save 保存当前防火墙规则。
#CentOS 7中防火墙配置:
firewall-cmd --permanent --add-port=23/tcp
firewall-cmd --reload
现在telnet服务已经可以使用了,下面我们来测试一下:
创建一个测试用户,并设置用户密码:
useradd telnettest
passwd telnettest
客户端配置,首先安装telnet客户端
yum install telnet
客户端安装完成之后,输入
telnet 199.99.99.189
输入上面创建的telnettest用户和密码登录
Trying 199.99.99.189...
Connected to 199.99.99.189.
Escape character is '^]'.
Kernel 3.10.0-123.13.2.el7.x86_64 on an x86_64
web2 login: telnettest
Password:
[telnettest@web2 ~]$
windows用户,安装了telnet客户端,同样也可以连接上服务器,当然很多其他telnet ssh软件也可以,如:SecureCRT、Putty等等
yum install telnet telnet-server -y
安装之后修改/etc/xinetd.d/telnet文件,把disable那一行改为disable = no,[注:如果是CentOS7请忽略这一步]
vi /etc/xinetd.d/telnet
# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}
修改完之后,保存并退出
#CentOS上启动telnet服务并设置开机启动
service xinetd start
chkconfig telnet on
chkconfig xinetd on
#CentOS 7上:
systemctl start telnet.socket
systemctl enable telnet.socket
#CentOS默认防火墙没有开放23端口,所以我们要根据需要允许23端口
vi /etc/sysconfig/iptables
加入一条“-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT”
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
保存并退出,然后重新启动iptables服务
service iptables restart
也可以输入以下命令:
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT
立即生效,然后输入 service iptables save 保存当前防火墙规则。
#CentOS 7中防火墙配置:
firewall-cmd --permanent --add-port=23/tcp
firewall-cmd --reload
现在telnet服务已经可以使用了,下面我们来测试一下:
创建一个测试用户,并设置用户密码:
useradd telnettest
passwd telnettest
客户端配置,首先安装telnet客户端
yum install telnet
客户端安装完成之后,输入
telnet 199.99.99.189
输入上面创建的telnettest用户和密码登录
Trying 199.99.99.189...
Connected to 199.99.99.189.
Escape character is '^]'.
Kernel 3.10.0-123.13.2.el7.x86_64 on an x86_64
web2 login: telnettest
Password:
[telnettest@web2 ~]$
windows用户,安装了telnet客户端,同样也可以连接上服务器,当然很多其他telnet ssh软件也可以,如:SecureCRT、Putty等等