Telnet服务器:
一 安装:
查找系统中否已经安装Telnet软件,可用如下命令
[fedora@localhost ~]$ rpm -qa | grep telnet
telnet-0.17-47.fc14.i686
telnet-server-0.17-47.fc14.i686
[fedora@localhost ~]$ yum list telnet
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Installed Packages
telnet.i686 1:0.17-47.fc14 @anaconda-InstallationRepo-201010211814.i386
[fedora@localhost ~]$
如果没有安装的话,可用安装光盘或直接使用yum在线安装,这里用yum直接在线安装:
#系统已经安装了telnet客户端,在这里只要安装server就好了。
[root@localhost ~]# yum install telnet-server
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package telnet-server.i686 1:0.17-47.fc14 set to be installed
--> Processing Dependency: xinetd for package: 1:telnet-server-0.17-47.fc14.i686
--> Running transaction check
---> Package xinetd.i686 2:2.3.14-32.fc14 set to be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
telnet-server i686 1:0.17-47.fc14 fedora 36 k
Installing for dependencies:
xinetd i686 2:2.3.14-32.fc14 fedora 121 k
Transaction Summary
================================================================================
Install 2 Package(s)
Total download size: 157 k
Installed size: 307 k
Is this ok [y/N]: y
............(省略)
二 启动与关闭:
*把xinetd里关于Telnet的项目打开。
*重新启动xinetd。
打开Telnet项目:
方法一:可以使用ntsysv或者chkconfig配置,不过此方法只适用于RED HAT系列。具体用法可以参照man
手册。
方法二:直接编辑/etc/xinetd.d/telnet文件:
[root@localhost ~]# 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 = yes
disable = no
#直接把上面的disable选项改成no就好了,其它一般不需改动。
}
设置完成后,重新启动xinetd就好了,因为telnet是挂在xinetd下面的,所以只要重启xinetd就能将先前的设置读进来。重启的方法如下:
方法一:只适用于Red Hat/Mandriva系列的主机启动方式
[root@localhost ~]# service xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]
方法二:
[root@localhost ~]# /etc/init.d/xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
*如果没有restart选项的话,就先stop再start
检查相关服务是否启动:
[root@localhost ~]# netstat -tlup |grep telnet
tcp 0 0 *:telnet *:* LISTEN 3852/xinetd
[root@localhost ~]# netstat -tlup |grep xinetd
tcp 0 0 *:telnet *:* LISTEN 3852/xinetd
可以看到相关服务已经启动了,那么如何关闭呢?其实很简单只要把刚刚的设置改回来就是啦:
步骤一:修改配置文件
[root@localhost ~]# 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 = yes
# disable = no
}
步骤二:重启xinetd
[root@localhost ~]# /etc/init.d/xinetd restart
三 联机
以联结本地主机为例:
[root@localhost ~]# telnet localhost
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Fedora release 14 (Laughlin)
Kernel 2.6.35.6-45.fc14.i686 on an i686 (2)
login: oracle
Password:
[oracle@localhost ~]$ ls -l
total 64
-rw-r--r-- 1 oracle oinstall 27 Apr 10 21:36 afiedt.buf
drwxr-xr-x. 6 oracle oinstall 4096 Mar 24 16:50 app
drwxr-xr-x 2 oracle oinstall 4096 Mar 31 23:25 Desktop
drwxr-xr-x 2 oracle oinstall 4096 Mar 24 15:41 Documents
drwxr-xr-x 3 oracle oinstall 4096 Mar 31 20:52 Downloads
drwxr-xr-x 2 oracle oinstall 4096 Mar 18 19:57 java_se
drwxr-xr-x 2 oracle oinstall 4096 Mar 15 22:37 Music
-rw-r--r-- 1 oracle oinstall 2157 Mar 24 16:53 mysqlplus.sql
-rw-r--r-- 1 oracle oinstall 51 Mar 24 16:50 ON.lst
drwxrwxr-x. 3 oracle oinstall 4096 Oct 15 14:02 oracle_for_linux
drwxr-xr-x 2 oracle oinstall 4096 Mar 15 22:37 Pictures
drwxr-xr-x 2 oracle oinstall 4096 Mar 15 22:37 Public
drwxr-xr-x 2 oracle oinstall 4096 Mar 15 22:37 Templates
-rw-r--r-- 1 oracle oinstall 124 Apr 8 21:11 test.sql
drwxr-xr-x 2 oracle oinstall 4096 Mar 15 22:37 Videos
drwxr-xr-x 5 oracle oinstall 4096 Mar 28 21:27 workspace
[oracle@localhost ~]$ exit
logout
Connection closed by foreign host.
注意事项:
因为Telnet的数据是以明文方式传输,很不安全,所以一般不要使用,如果硬是要启动Telnet应该使用iptables来限制联机的范围再加上TCP Wrappersr的辅助,加强防火强的功能,并在使用之后立即关闭Telnet。
不能让root用户以Telnet身份登录Linux主机,并随时关注日志文件里关于login的事项。