1. 配置yum缓存保存缓存
vi /etc/yum.conf
2. 清除yum缓存,并且设置保存缓存且自动建立依赖之间的索引
yum clean all && yum makecache
3. 安装 perl
wget https://www.cpan.org/src/5.0/perl-5.36.0.tar.gz tar -xzf perl-5.36.0.tar.gz cd perl-5.36.0 ./Configure -des -Dprefix=$HOME/localperl make make test make install
4. 安装依赖
yum -C install distro-sync rpm-build zlib-devel openssl-devel gcc perl-devel pam-devel xmkmf libXt-devel gtk2-devel make
5. perl安装
5.1. perl 在线模式安装: IPC/Cmd.pm
yum install -y perl-CPAN
5.1.1 per 交互模式
perl -MCPAN -e shell cpan[1]> install IPC/Cmd.pm
6. 安装 zlib
wget http://zlib.net/zlib-1.2.12.tar.gz tar -xvf zlib-1.2.12.tar.gz cd zlib-1.2.12 ./configure make && make install
6.openSSL 安装
wget --no-check-certificate https://www.openssl.org/source/openssl-3.0.5.tar.gz tar -xvf openssl-3.0.5.tar.gz cd openssl-3.0.5 ./config -fPIC --openssldir=/etc/pki/tls --prefix=/etc/pki/tls shared zlib make && make install
备份:
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
配置指向新版
ln -s /etc/pki/tls/bin/openssl /usr/bin/openssl
ln -s /etc/pki/tls/include/openssl /usr/include/openssl
配置库文件
ln -sf /etc/pki/tls/lib64/libssl.so.3 /usr/lib64/libssl.so.3
ln -sf /etc/pki/tls/lib64/libcrypto.so.3 /usr/lib64/libcrypto.so.3
配置文件生效
echo "/etc/pki/tls/lib64" >> /etc/ld.so.conf
ldconfig -v
openssl 这里已经升级完成,通过openssl version -a 可以查看下当前openssl的版本信息:
7.openssh安装
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.0p1.tar.gz tar -zxvf openssh-9.0p1.tar.gz cd openssh-9.0p1 mv /etc/ssh /etc/ssh.bak //备份配置文件 ./configure --prefix=/usr/local/openssh9.0 --sysconfdir=/etc/ssh/ --with-md5-passwords --mandir=/usr/share/man --with-zlib --with-pam --with-ssl-dir=/etc/pki/tls/ make && make install
安装完成后通过这个命令检测一下配置文件:
/usr/local/openssh9.0/sbin/sshd -t -f /etc/ssh/sshd_config
修改配置文件:
echo "X11Forwarding yes" >> /etc/ssh/sshd_config echo "X11UseLocalhost no" >> /etc/ssh/sshd_config echo "XAuthLocation /usr/bin/xauth" >> /etc/ssh/sshd_config echo "UseDNS no" >> /etc/ssh/sshd_config echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config echo 'KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1' >> /etc/ssh/sshd_config
更新备份ssh相关执行脚本:
mv /usr/sbin/sshd /usr/sbin/sshd20220825.bak cp -rf /usr/local/openssh9.0/sbin/sshd /usr/sbin/sshd mv /usr/bin/ssh /usr/bin/ssh20220825.bak cp -rf /usr/local/openssh9.0/bin/ssh /usr/bin/ssh mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen2022-08-25.bak cp -rf /usr/local/openssh9.0/bin/ssh-keygen /usr/bin/ssh-keygen
更换sshd的启动脚本:
rm -rf /usr/lib/systemd/system/sshd.service
在解压的openssh安装包目录下执行:
cp contrib/redhat/sshd.init /etc/init.d/sshd
最后再执行:
systemctl enable sshd.service systemctl daemon-reload systemctl restart sshd
参考博客:centos7的openssl和openssh升级到最新版本分别为3.0.5和9.0.p1_qq_28684191的博客-CSDN博客_openssh最新版本