安装之前了解一下Telnet,在公共网络上用telnet传输数据不安全,建议只在本地网络上使用
Using Telnet in public network(WAN) is very very bad idea. It transmits login data in the clear format. Everything will be sent in plain text.
If you still need Telnet, It is highly recommended use it in the local area network only.
Alternatively, you can use SSH. But make sure you’ve disabled root login in SSH.
Telnet是通过TCP/IP协议来连接远程计算机的,一旦建立连接后,它就变成来虚拟终端,由此实现本地和远程的通信。
Telnet is a network protocol which is used to connect to remote computers over TCP/IP network. Once you establish a connection to the remote computer, it becomes a virtual terminal and will allow you to communicate with the remote host from your local system.
In this brief tutorial, let us see how to install Telnet, and how to access remote systems via Telnet.
Installation
Open your terminal and type the following command to install telnet:
1,在服务器上安装telnet使用:
yum install telnet telnet-server -y
2,编辑telnet的配置文件
centOS7可以略过这步,本机为centOS6.7
Be mindful that you don’t have do this step in CentOS 7
edit the telnet configuration file /etc/xinetd.d/telnet;
vi /etc/xinetd.d/telnet
把disable设置为no
Set disable = no:
如下
# 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
}
3,Save and quit the file. .
4,重启telnet服务
Now restart the telnet service using the following command:
On CentOS 6.x systems:
service xinetd start
5,在启动服务器时,自动启动telnet服务,可做如下设置
Make this service to start automatically on every reboot:
On CentOS 6:
chkconfig telnet on
chkconfig xinetd on
On CentOS 7:
systemctl start telnet.socket
systemctl enable telnet.socket
6,让telnet默认端口通过防火墙,centOS6.x上,编辑iptables
To allow the telnet port through firewall, Edit file /etc/sysconfig/iptables on CentOS 6.x systems:
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
centOS7,可使用如下命令
On CentOS 7, run the following commands to enable telnet service through firewall.
firewall-cmd --permanent --add-port=23/tcp
firewall-cmd --reload
Save and exit the file.
7,重启iptables服务
Restart iptables service:
service iptables restart
到这里,服务器端telnet就安装好了
创建测试用户,用户名 sk, 密码centos
useradd sk
passwd sk
8,客户端安装telnet
安装 telnet 包:
yum install telnet
在ubnutu上使用如下命令:
sudo apt-get install telnet
9,打开终端,连接服务器
Now, open Terminal, and try to access your server(remote host).
telnet 服务器ip
telnet 192.168.1.150
10,输入在服务器上设置的用户名密码
Enter username and password which we have created in the server:
Sample output:
Trying 192.168.1.150...
Connected to 192.168.1.150.
Escape character is ‘^]‘.
Kernel 3.10.0-123.13.2.el7.x86_64 on an x86_64
server1 login: sk
Password:
[[email protected] ~]$
11,ok. That’s it.
Cheers!
原文地址
http://www.unixmen.com/installing-telnet-centosrhelscientific-linux-6-7/