由于目前服务器上ssh版本较低,存在安全漏洞,需要升级到最新版本。
系统版本:RedHat 6.6
旧openSSH版本:5.3p1
新openSSH版本:7.4p1
升级方式:源码安装
1.更新ssl
yum update openssl
更新ssl到OpenSSL 1.0.1e-fips
2.备份ssh目录
cp -rf /etc/ssh /etc/ssh.bak
3.安装telnet,以备ssh更新失败无法远程连接,如果可以现场操作可忽略
4.安装升级所需组件
yum install -y gcc openssl-devel pam-devel rpm-build
5.解压升级包,并安装(如需卸载旧版openSSH,查看步骤8)
tar -zxvf openssh-7.4p1.tar.gz
cd openssh-7.4p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords
make && make install
安装后提示
/etc/ssh/ssh_config already exists, install will not overwrite
/etc/ssh/sshd_config already exists, install will not overwrite
/etc/ssh/moduli already exists, install will not overwrite
ssh-keygen: generating new host keys: ECDSA ED25519
/usr/sbin/sshd -t -f /etc/ssh/sshd_config
/etc/ssh/sshd_config line 81: Unsupported option GSSAPIAuthentication
/etc/ssh/sshd_config line 83: Unsupported option GSSAPICleanupCredentials
6.修改配置文件允许root用户远程登陆
vim /etc/ssh/sshd_config
#PermitRootLogin yes
修改为
PermitRootLogin yes
7.重启openSSH
service sshd reload
8.如果需要卸载旧版openSSH
查看旧版openSSH
rpm -qa | grep openssh
卸载旧版openSSH
rpm -e `rpm -qa | grep openssh` --nodeps
9.安装新版openSSH
tar -zxvf openssh-7.4p1.tar.gz
cd openssh-7.4p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords
make && make install
10.复制启动脚本到/etc/init.d
cp /xx/openssh-7.4p1/contrib/RedHat/sshd.init /etc/init.d/sshd
11.加入开机启动
12.启动sshd
用start或reload。不要restart,restart 会直接断开连接,而并不会接着启动sshd服务,这时候要通过其他途径进入机器,然后启动sshd服务才行。
13.查看ssh版本
ssh -V
参考:
http://blog.csdn.net/levy_cui/article/details/53100315
http://www.2cto.com/os/201510/445119.html