如何在centos下开启telnet服务


本文摘自PHP中文网,作者WJ,侵删。

如何在centos下开启telnet服务

1.查看linux版本信息:

1

2

[loong@localhost ~]$ cat /etc/issue

CentOS release 5.8 (Final)Kernel \r on an \m

2. 查看系统是否已安装telnet-server,linux系统上默认已经安装telnet-client(或telnet),而telnet-server需要手动安装。

1

2

[loong@localhost ~]$ rpm -qa | grep telnet

telnet-0.17-39.el5

3. 安装telnet-server,若系统已安装,跳过此步。

方法一:下载RPM resource telnet-server

选择相应版本的telnet-server下载;

安装:# rpm -i telnet-server-0.17-39.el5.i386.rpm #貌似还得单独安装xinetd.

方法二:(推荐使用)

1

# yum install telnet-server

安装完成后:

1

2

3

[loong@localhost ~]$ rpm -qa | grep telnet

telnet-0.17-39.el5

telnet-server-0.17-39.el5

4. 启动telnet服务

方法一:System->Administration->Services 中,

On Demand Services中选中telnet

并在Background Services中选中xinetd,并点击上面的Start,即在右侧显示:xinetd (pid 15986) is running...

最后Save & Quit.

方法二:编辑/etc/xinetd.d/telnet, 将其中的 disable = yesyes改为no.

修改后:

1

2

# 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
log_on_failure += USERID
}

方法三:使用chkconfig命令直接开启

1

[root@localhost loong]# chkconfig telnet on

注:方法二和方法三,需要激活xinetd服务。方法如下:

1

2

3

[root@localhost loong]# service xinetd restart

Stopping xinetd:                                           [  OK  ]

Starting xinetd:                                           [  OK  ]

或:

1

2

3

[root@localhost loong]# /etc/rc.d/init.d/xinetd restart

Stopping xinetd:                                           [  OK  ]

Starting xinetd:                                           [  OK  ]

5. 测试服务

1

2

3

4

5

6

[root@localhost loong]# telnet localhost

Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.CentOS release 5.8 (Final)Kernel 2.6.18-308.1.1.el5 on an i686

login: loong

Password:

Last login: Tue Apr 24 16:42:06 from 10.108.14.135[loong@localhost ~]$ exitlogout

Connection closed by foreign host.[root@localhost loong]#

注:默认情况下,系统只允许普通用户telnet登录,不允许root用户登录。

要想获得root权限,可以使用普通用户登录,然后执行su,来获得root权限。

或使用一下方法,允许root登录telnet:

方法一:# mv /etc/securetty /etc/securetty.bak (不建议这种方法,测试完后再改回去吧!)

或先试图使用root用户登录,不成功,然后查看系统log:

1

2

3

4

5

6

7

8

9

10

11

12

13

telnet> o localhost

Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.CentOS release 5.8 (Final)Kernel 2.6.18-308.1.1.el5 on an i686

login: root

Password:

Login incorrect

login:    

Login incorrect

login:

Login incorrect

login:

Connection closed by foreign host.[root@localhost loong]# tail -20 /var/log/secure

Apr 24 17:32:58 localhost login: pam_securetty(remote:auth): access denied: tty 'pts/1' is not secure !

Apr 24 17:33:03 localhost login: FAILED LOGIN 1 FROM localhost FOR root, Authentication failure

1

2

3

4

可以看到 access denied: tty 'pts/1' is not secure !

所以将‘pts/1’添加到/etc/securetty中,即可实现telnet的root用户登录。至于为什么?暂不清楚。

方法二:修改/etc/pam.d/remote,注释掉:auth       required     pam_securetty.so

1 #%PAM-1.02 #auth       required     pam_securetty.so3 auth       include      system-auth

注:不建议开放telnet的root登录,容易带来安全隐患。

相关参考:centOS教程

以上就是如何在centos下开启telnet服务的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

CentOS系统下包更新的命令

CentOS系统中文文件名乱码

CentOS下ip配置失败怎么办

CentOS ios镜像文件的实例详解

有关CentOS部署yapi的问题记录

CentOS系统如何查看端口是否开放

CentOS系统怎么通过win10的远程桌面连接进行远程访问

CentOS怎么退出图形界面

CentOS怎么赋予普通用户root权限

CentOS8怎么基于pxe自动安装操作系统

更多相关阅读请进入《CentOS》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...