首先说明我的系统环境:Ubuntu 10.10 x86 Desktop
在这个系统上默认只安装了telnet(也就是client)root@www.linuxidc.com:~# dpkg -s telnet
Package: telnet
Status: install ok installed
Priority: standard
Section: net
Installed-Size: 188
Maintainer: Ubuntu Developers
Architecture: i386
Source: netkit-telnet
Version: 0.17-36build1
Replaces: netstd
Provides: telnet-client
所以只能用telnet命令登录别人开启telnet服务的主机,其他人是不能使用telnet登录本机的。
1,现在要说的就是让别人能够使用telnet登录本机,需要安装两个软件:root@www.linuxidc.com:~# apt-get install telnetd
root@www.linuxidc.com:~# apt-get install xinetd
其中telnetd是telnet-server,但它是无法自我启动的,需要管理daemon的软件xinetd来接管。root@www.linuxidc.com:~# dpkg -s telnetd
Package: telnetd
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 152
Maintainer: Ubuntu Developers
Architecture: i386
Source: netkit-telnet
Version: 0.17-36build1
Replaces: netstd
Provides: telnet-server
2,通过xinetd启动telnetd,方法是新建telnet文件,并输入如下内容(没有安全性设置)root@www.linuxidc.com:~#vi /etc/xinetd.d/telnet
service telnet
{
disable=no
socket_type=stream
flags=REUSE
wait=no
user=root
server= /usr/sbin/in.telnetd #特别注意此处,in.telnetd是telnetd安装产生的文件
log_on_failure += USERID
}
如果要修改telnet的默认端口号(23),需要修改/etc/services文件中对应的telnet
3,然后重启xinetd程序root@www.linuxidc.com:/etc/xinetd.d# service xinetd restart
* Stopping internet superserver xinetd [ OK ]
* Starting internet superserver xinetd [ OK ]
这时候可以是使用netstat命令查看23端口监听情况root@www.linuxidc.com:~# netstat -tulnp | grep 23
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN 4176/xinetd
4,可以确定telnet服务器已经搭建完成,这时只需要换个电脑,然后使用telnet ip即可登录。默认的设定是root不能通过telnet登录(telnet在网络上是明文传输,可以被sniffer侦测出密码),如果安全性有保证,可以通过一下方法允许root登录:
(1)修改/etc/securetty文件,添加终端root@www.linuxidc.com:~# tail -5 /etc/securetty
pts/0
pts/1
pts/2
pts/3
pts/4
或者直接将securetty文件改名,即可使用root登录
(2)修改/etc/pam.d/login文件,将securetty验证注释调12 # Disallows root logins except on tty's listed in /etc/securetty
13 # (Replaces the `CONSOLE' setting from login.defs)
14 # Note that it is included as a "required" module. root will be
15 # prompted for a password on insecure ttys.
16 # If you change it to a "requisite" module, make sure this does not leak
17 # user name information.
18 #auth required pam_securetty.so
这样telnet基本上就配置完成了,不过还是建议大家用ssh(但windows系统要用ssh还要附加专门的软件,真的很艹蛋!