一、 备份ssh目录
cp -rf /etc/ssh/etc/ssh.bak
二、安装telnet
避免ssh升级出现问题,导致无法远程管理,需要安装telnet服务(若在本机操作,则不需要安装telnet)
在线安装:
[[email protected]~]# yum install xinetd
[[email protected] ~]#yum install telnet
[[email protected]~]# yum install telnet-server
离线安装(64位需要64位安装包,32位需要32位安装包)
rpm -ivhxinetd-2.3.14-39.el6_4.x86_64.rpm
rpm -ivh telnet-0.17-48.el6.x86_64.rpm
rpm -ivh telnet-server-0.17-48.el6.x86_64.rpm
安装完telnet服务后默认是不开启的,需要开启telnet服务:
[[email protected]~]# vi /etc/xinetd.d/telnet
修改disable=no
**xinetd服务:
[[email protected]~]# service xinetd restart //第一次可能会失败,若失败请多试几次
默认不允许root登录,需要修改允许root登录:
[[email protected]~]# vi /etc/securetty
增加:
pts/1
pts/2
pts/3
注:网上说若用户比较多,可直接pts/*,本人在此版本测试的时候未生效
重启服务:
[[email protected]~]# /etc/init.d/xinetd restart
关闭防火墙,不然可能无法telnet登录(关闭防火墙的方式有多种,这里使用setup来关闭)
使用Setup 来设置关闭防火墙。
三、安装gcc等依赖
在线安装gcc,这是最简单的:
[[email protected]]# yum install -y gcc openssl-devel pam-devel rpm-build
离线安装,所有依赖需要自己下载rpm包来按照顺序安装(顺序不能乱),这里我都弄好了,从1开始就行了(百度网盘自取,链接在最下面)
rpm –ivh 1ppl-0.10.2-11.el6.i686.rpm
四、升级openssh
在线升级:
直接下载就行了,这里升级的是7.3,可根据自己需求来下载相关版本:
[[email protected]~]# wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.3p1.tar.gz
离线升级:自己下载好,传到服务器咯
解压升级包:
[[email protected]~]# tar -zxvf openssh-7.3p1.tar.gz
[[email protected]~]# cd openssh-7.3p1
检查配置:
[[email protected]]# ./configure --prefix=/usr --sysconfdir=/etc/ssh--with-md5-passwords --with-pam --with-tcp-wrappers--with-ssl-dir=/usr/local/ssl --without-hardening
编译安装:
[[email protected]]# make && make install
修改配置文件,允许root登录:
[[email protected]]# vi /etc/ssh/sshd_config
#PermitRootLoginyes 前面的#去掉
或者用以下命令:
sed -i'/^#PermitRootLogin/s/#PermitRootLogin yes/PermitRootLogin yes/'/etc/ssh/sshd_config
重启openssh:
[[email protected] openssh-7.3p1]#service sshd restart
设置下开机启动:
[[email protected]]chkconfig sshd on
大功告成!!!!!!!!!!!!!!
网盘链接:
链接:https://pan.baidu.com/s/1PDHMkoECUU4zPntGQjFgVg密码:e5jg