红联Linux门户
Linux帮助
当前位置: 红联Linux门户 > Debian

debain linux os安装telnet server

发布时间:2007-12-12 00:31:46来源:红联作者:skurialtn
注意:本文讨论的是telnet server,不是telnet client。

debain linux的telnet server是挂在xinet.d上(用netstat命令查看也能反映),即telnet的操作是/etc/init.d/xinet.d force-reload|reload|restart|start|stop。

本文在debain(2.6.18-4-686)和ubuntu(2.6.20-15-generic)均测试成功,以下为安装步骤(以ubuntu为例):

安装internet superserver: xinetd.
root@zhoudh-desktop:/# apt-get install xinetd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
xinetd
0 upgraded, 1 newly installed, 0 to remove and 166 not upgraded.
Need to get 135kB of archives.
After unpacking 369kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
xinetd
Install these packages without verification [y/N]? y
Get:1 http://cn.archive.ubuntu.com feisty/main xinetd 1:2.3.14-1ubuntu1 [135kB]
Fetched 135kB in 44s (3009B/s)
Selecting previously deselected package xinetd.
(Reading database ... 90150 files and directories currently installed.)
Unpacking xinetd (from .../xinetd_1%3a2.3.14-1ubuntu1_i386.deb) ...
Setting up xinetd (2.3.14-1ubuntu1) ...
Stopping internet superserver: xinetd.
Adding `diversion of /etc/init.d/inetd to /etc/init.d/inetd.real by xinetd'
Starting internet superserver: xinetd.

安装telnet server
安装软件
root@zhoudh-desktop:/# apt-get install telnetd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
telnetd
0 upgraded, 1 newly installed, 0 to remove and 166 not upgraded.
Need to get 0B/42.0kB of archives.
After unpacking 147kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
telnetd
Install these packages without verification [y/N]? y
Selecting previously deselected package telnetd.
(Reading database ... 90170 files and directories currently installed.)
Unpacking telnetd (from .../telnetd_0.17-35ubuntu1_i386.deb) ...
Setting up telnetd (0.17-35ubuntu1) ...

安装完毕后,系统会在/etc/inetd.conf加上一行信息:
telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
root@zhoudh-desktop:/# cat /etc/inetd.conftelnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd

如没有这一行,请加上。

修改配置文件
root@zhoudh-desktop:/# cd /etc/xinetd.d/
root@zhoudh-desktop:/etc/xinetd.d# vi telnet

# default: on

# description: The telnet server serves telnet sessions; it uses \

# unencrypted username/password pairs for authentication.

service telnet

{

disable = no

flags = REUSE

socket_type = stream

wait = no

user = root

server = /usr/sbin/in.telnetd

server_args = -h

log_on_failure += USERID


}
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"telnet" [New File] 29 lines, 435 characters written
root@zhoudh-desktop:/etc/xinetd.d#

网上例子在创建telnet配置文件时用的是nano -w /etc/xinetd.d/telnet,但事实上用vi就可以了。

安装telnet client
root@zhoudh-desktop:/# apt-get install telnet
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
telnet
0 upgraded, 1 newly installed, 0 to remove and 166 not upgraded.
Need to get 0B/65.6kB of archives.
After unpacking 188kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
telnet
Install these packages without verification [y/N]? y
Selecting previously deselected package telnet.
(Reading database ... 90182 files and directories currently installed.)
Unpacking telnet (from .../telnet_0.17-35ubuntu1_i386.deb) ...
Setting up telnet (0.17-35ubuntu1) ...

重启xinetd服务
root@zhoudh-desktop:/# /etc/init.d/xinetd reload
Reloading internet superserver configuration: xinetd.
root@zhoudh-desktop:/# /etc/init.d/xinetd restart
Stopping internet superserver: xinetd.
Starting internet superserver: xinetd.
root@zhoudh-desktop:/# netstat -anp | grep LISTEN
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN 4609/hpiod
tcp 0 0 0.0.0.0:2401 0.0.0.0:* LISTEN 20744/xinetd
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN 20744/xinetd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 5566/cupsd
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN 4612/python
tcp6 0 0 :::22 :::* LISTEN 4772/sshd
unix 2 [ ACC ] STREAM LISTENING 15635 4820/hcid /var/run/sdp
......

0 0.0.0.0:23即为telnet server守护进程(telnet默认监听端口为23),说明telnet server已启动。

测试连接
取本机ip
root@zhoudh-desktop:/# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:CE:B5:3F
inet addr:192.168.200.254 Bcast:192.168.200.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fece:b53f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6632 errors:0 dropped:0 overruns:0 frame:0
TX packets:5387 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2339516 (2.2 MiB) TX bytes:790404 (771.8 KiB)
Interrupt:18 Base address:0x1400

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3402 errors:0 dropped:0 overruns:0 frame:0
TX packets:3402 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:143116 (139.7 KiB) TX bytes:143116 (139.7 KiB)

在另一台机子上用telnet登录
zhoudh-desktop login: root

Login incorrect
zhoudh-desktop login: zhoudh
Password:
Last login: Mon Dec 10 16:43:40 2007 from 192.168.200.250 on pts/2
Linux zhoudh-desktop 2.6.20-15-generic #2 SMP Sun Apr 15 07:36:31 UTC 2007 i686

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
zhoudh@zhoudh-desktop:~$

从上面我们可以看到我们已经连接成功了,但是使用root连接的时候会失败,因为默认的安全设置是限制root用户使用telnet连接主机的。

允许root登录
修改配置文件
root@zhoudh-desktop:~# vi /etc/pam.d/login
auth requisite pam_securetty.so
-〉#auth requisite pam_securetty.so
网上例子用nano /etc/pam.d/login。
用root登录
由于ubuntu不提供root用户,所以这个只能在debain上测试
localhost login: root
Password:
Last login: Tue Dec 11 06:10:06 2007 from 192.168.200.250 on pts/0
Linux localhost 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 2007 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
1 failure since last login.
Last was Tue 11 Dec 2007 06:10:37 AM EST on pts/0.
localhost:~#

当然不建议允许root telnet登录。
文章评论

共有 0 条评论