赞
踩
本次使用在线升级,因此要求系统yum、wget等功能能正常使用。
环境:
cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
1. 升级 过程中,sshd可能无法使用,因此需要安装telnete服务
yum -y install xinetd telnet-server
2.允许root远程登录telnet
sed -i "2s/^/#/g" /etc/pam.d/login
3.添加超级用户登陆设备至/etc/securetty文件
for i in `seq 0 10` ;do echo "pts/$i" >> /etc/securetty;done
4.重启telnet和xinetd服务【telnet服务依赖于xinetd服务】
systemctl restart telnet.socket
systemctl restart xinetd
5.验证telnet登录是否正常
5.关闭防火墙和selinux
systemctl stop firewalld
systemctl disable firewalld
systemctl stop iptables
systemctl disable iptables
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config && setenforce 0
6.安装依赖包
yum -y install gcc make perl zlib zlib-devel pam pam-devel
7.升级Openssh
这一步骤需要分别下载、预编译、编译、安装,并刷新加载生成的相应的库文件
zlib-1.2.11.tar.gz
openssl-1.0.2o.tar.gz
openssh-9.2p1.tar.gz
这个压缩包地址为:
链接:https://pan.baidu.com/s/1A9uNnpaeeZyuBwPukQ4WGg
提取码:6666
--来自百度网盘超级会员V5的分享
a)备份ssh配置文件
cp -r /etc/ssh /etc/ssh.old
b)卸载系统原有openssh包,并验证是否卸载成功
rpm -e --nodeps $(rpm -qa | grep openssh)
rpm -qa | grep openssh
c)安装zlib
wget https://www.cmdeye.com/wp-content/uploads/shell/openssl/zlib-1.2.11.tar.gz
tar -xzvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make && make install
d)新建并编辑zlib配置文件,并刷新库文件,加载刚才编译安装的zlib生成的库文件
echo '/usr/local/zlib/lib' >>/etc/ld.so.conf.d/zlib.conf
ldconfig -v
e)编译安装openssl
wget https://www.cmdeye.com/wp-content/uploads/shell/openssl/openssl-1.0.2o.tar.gz
tar -xzvf openssl-1.0.2o.tar.gz
cd openssl-1.0.2o
./config shared zlib
make && make install
f)重命名现有文件目录,并创建ssl相关软连接
mv /usr/bin/openssl /usr/bin/openssl.bak
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
g)编辑配置文件
echo '/usr/local/ssl/lib' >>/etc/ld.so.conf.d/ssl.conf
h)刷新库文件,加载刚才编译安装的ssl生成的库文件
ldconfig -v
h)更新openssl-devel包,升级openssh
yum -y install openssl-devel
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.2p1.tar.gz
tar -zxvf openssh-9.2p1.tar.gz
cd openssh-9.2p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-zlib --without-openssl-header-check --with-ssl-dir=/usr/local --with-privsep-path=/var/lib/sshd
make
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key
make install
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
以上,升级完成,但是ssh服务启动,需要进行一些配置:
cp -p contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
chkconfig --add sshd
chkconfig sshd on
systemctl restart sshd
至此,openssh升级成功。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。