标签: linux Telnet远程登录 在Linux(我用的Red Hat9.0)操作系统中,首先确保系统安装了telnet-server软件包。查看是否安装此软件包的命令: [root@localhost root]#rpm -qa | grep telnet telnet-0.17-25 // telnet客户端(默认安装) telnet-server-0.17-25 // telnet服务软件包 如果没有安装,请在Linux第3张安装盘中找到telnet-server-0.17-25-i386.rpm软件包。安装命令如下: [root@localhost root]#rpm -ivh telnet-server-0.17-25-i386.rpm 在默认情况下,Linux服务不会开启,并用不像(如HTTP、FTP)要一样作为独立的守护进程来运行,而使用xinetd(entended internet services daemon)程序来管理,提高了系统的安全性。 (1)修改本机Linux服务配置文件/etc/xinted.d/telnet,将disable行属性改为no,其它保存默认就可。 [root@localhost root]#vi /etc/xinetd.d/telnet # default: on # description: The telnet server serves telnet sessions;it user / .... service telnet { disable = no // 默认是yes,改为no flags = Reuse socket_type = stream ... } (2)查看/etc/services/中的telnet端口是否为23.也改可以改为其它端口号。不过登录的时候,需要打以下命令: telnet IP地址 端口号 [root@localhost root]#cat /etc/services ... ssh 22/tcp #SSH Remote Login Protocol ssh 22/udp telnet 23/tcp # telnet port telnet 23/tcp (3)查询与重新启动Telnet远程登录服务 [root@localhost root]#chkconfig telnet on // 设置默认启用 [root@localhost root]#service xinetd restart // 重新启用 Stopping xinetd: [OK] Starting xinetd: [OK] (4)测试效果:telnet 202.101.1.1 (5)设置根用户可以登录 默认情况下,根用户是不可以登录的。有二种办法: 一、用普通用户登录,然后用命令su - 更改到root用户就可以了 二、修改/etc/pam.d/login [root@localhost root]#vi /etc/pam.d/login #%PAM-1.0 #auth required pam_securetty.so / /此行注释掉,在前面加个#符号...... (6)限制登录设置 为了telnet的登录安全性,可以限制访问IP、访问时间、最大连接数目等尽可能地提高安全性。修改/etc/xinetd.d/telnet文件。然后, 重新启用服务。 [root@localhost root]#vi /etc/xinetd.d/telnet .... { disable =no // 开启telnet服务 ind=192.168.1.1 // 服务器有多个IP地址,设置本地telnet服务器IP only_from=192.168.1.0/24 // 只允许这个网段的IP登录 only_from=.edu.cn // 只允许教育网进入 o_access=192.168.1.{1,2} // 只有这两台主机可以登录 access_times=8:00-12:00 14:00-16:00 // 限制这两个时间段来使用telnet服务 instances=3 // 连接最大数 ... } (7)因为telnet在数据传输时,是明文的(通过嗅探器可以抓到口令与密码) 上面明显可以看到用户名为:redhat,密码为:redhat.所以,远程登录尽量不要用telnet,可以用SSH来替代--下次再把SSH服务写出来。