Centos(5.8)开启telnet服务,当需要升级openssh的时候

来源:互联网 发布:mac系统装win8最新方法 编辑:程序博客网 时间:2024/06/06 08:45
CentOS5.8上安装telnet服务

当你需要升级openssh的时候,为了避免中途升级失败,导致远程不上,先将telnet开启。

1.查看系统版本及是否安装telnet

    [root@centos32 comodo]# cat /etc/issue
    CentOS release 5.8 (Final)
    Kernel \r on an \m
    [root@centos32 comodo]# rpm -qa|grep telnet
    telnet-0.17-39.el5

其中CentOS系统默认已经安装了telnet,但是telnet-server软件包需要自行安装

2.安装telnet-server
    1.可以下载rpm包安装(下载地址:http://rpmfind.net/linux/rpm2html/search.php?query=telnet-server)
    2.可以#yum install telnet-server
安装完成后检查安装是否成功:

    [root@centos32 comodo]# rpm -qa|grep telnet
    telnet-0.17-39.el5
    telnet-server-0.17-39.el5

3.启动telnet服务
    方法1:图形桌面System->Administration->Services->"On Demand Services"菜单页选中telnet并保存
    方法2:图形桌面Applications->Accessories->Terminal中输入#/usr/sbin/ntsysv回车选中telnet并保存
    方法3:修改/etc/xinetd.d/telnet将disable = yes修改为no, 可以使用命令#sed -i 's/disable = yes/disable = no/' /etc/xinetd.d/telnet
    方法4:修改启动项#/sbin/chkconfig telnet on
    方法3和方法4需要重启telnet服务,运行命令#/etc/rc.d/init.d/xinetd restart

4.测试服务

    [root@centos32 comodo]# 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.16.1.el5 on an i686
    login: comodo
    Password:
    Last login: Thu Dec 6 15:19:27 from debian32
    [comodo@centos32 ~]$ exit(此处可知telnet已经使用用户comodo成功登录)
    logout
    Connection closed by foreign host.
    [root@centos32 comodo]#


5.允许root登录telnet(默认情况下,telnet禁止root用户登录)
    方法1.修改/etc/pam.d/remote注释掉auth    required    pam_securetty.so

    [root@centos32 comodo]# vim /etc/pam.d/remote
    #%PAM-1.0
    #auth required pam_securetty.so

    方法2.先查看root登录使用的伪终端号,然后把这个伪终端加到/etc/securetty中
step 1:打开一个终端输入

    [root@centos32 comodo]# 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.16.1.el5 on an i686
    login: root
    Password:
    Login incorrect
    login: Login timed out after 60 seconds
    Connection closed by foreign host.

step 2:打开一个终端输入

    [root@centos32 comodo]#tail /var/log/secure
    Dec 6 15:51:15 centos32 login: pam_securetty(remote:auth): access denied: tty 'pts/7' is not secure !
    Dec 6 15:51:18 centos32 login: FAILED LOGIN 1 FROM centos32 FOR root, Authentication failure

step 3:把pts/7加入到/etc/securetty后,telnet即可使用root账户登录

    [root@centos32 comodo]# vim /etc/securetty
    pts/7

当你需要升级openssh的时候,为了避免中途升级失败,导致远程不上,先将telnet开启。
0 0
原创粉丝点击