前期准备,安装包:
tools.zip
zlib-1.2.11.tar.gz
openssl-3.3.1.tar.gz
openssh-9.8p1.tar.gz
----------
使用管理员帐户登陆:
root/******
查看版本号:
ssl版本查询方法:
openssl version
ssh版本查询方法:
ssh -V
创建目录:
mkdir /backup
登陆目录:
cd /backup
新建目录:
mkdir /backup/tools
登陆目录:
cd /backup/tools
将tools包上传,解压:
unzip tools.zip
解压后所有文件到目录:
inflating: gdbm-devel-1.10-8.el7.x86_64.rpm
inflating: libdb-devel-5.3.21-25.el7.x86_64.rpm
inflating: perl-devel-5.16.3-299.el7_9.x86_64.rpm
inflating: perl-ExtUtils-Install-1.58-299.el7_9.noarch.rpm
inflating: perl-ExtUtils-MakeMaker-6.68-3.el7.noarch.rpm
inflating: perl-ExtUtils-Manifest-1.61-244.el7.noarch.rpm
inflating: perl-ExtUtils-ParseXS-3.18-3.el7.noarch.rpm
inflating: perl-IPC-Cmd-0.80-4.el7.noarch.rpm
inflating: perl-Locale-Maketext-1.23-3.el7.noarch.rpm
inflating: perl-Locale-Maketext-Simple-0.21-299.el7_9.noarch.rpm
inflating: perl-Module-CoreList-2.76.02-299.el7_9.noarch.rpm
inflating: perl-Module-Load-0.24-3.el7.noarch.rpm
inflating: perl-Module-Load-Conditional-0.54-3.el7.noarch.rpm
inflating: perl-Module-Metadata-1.000018-2.el7.noarch.rpm
inflating: perl-Params-Check-0.38-2.el7.noarch.rpm
inflating: perl-version-0.99.07-6.el7.x86_64.rpm
inflating: pyparsing-1.5.6-9.el7.noarch.rpm
inflating: systemtap-sdt-devel-4.0-13.el7.x86_64.rpm
在目录下执行命令:
rpm -ivhU * --nodeps --force
将文件拷贝到目录下:
openssl-3.3.1.tar.gz
openssh-9.8p1.tar.gz
zlib-1.2.11.tar.gz
解压文件:
openssl-3.3.1.tar.gz
tar xvf openssl-3.3.1.tar.gz
先升级ssl,再升级ssh:
查看版本:
openssl version -a
查看命令所在目录:
which openssl
查看相关安装包:
rpm -qa|grep openssl
编译安装:
mkdir -p /usr/local/openssl
cd /backup/openssl-3.3.1/
./config --prefix=/usr/local/openssl
正式安装:
make && make install
备份老版本openssl相关数据:
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old
配置软链接:
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
echo "/usr/local/openssl/lib64/" >> /etc/ld.so.conf
查看生效版本:
cd /backup/openssl-3.3.1
ldconfig
查看升级后的新版本:
openssl version
查看详细版本:
openssl version -a
升级完ssl,再升级ssh:
查看版本:
ssh -V
解压文件openssh-9.8p1.tar.gz:
tar xvf openssh-9.8p1.tar.gz
解压文件zlib-1.2.11.tar.gz:
tar xvf zlib-1.2.11.tar.gz
进入zlib目录:
cd /backup/zlib-1.2.11/
编译安装:
./configure --prefix=/usr/local/zlib
make && make install
进入ssh目录:
cd /backup/openssh-9.8p1/
编译安装:
./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/openssl --sysconfdir=/etc/ssh --without-openssl-header-check
make && make install
修改文件sshd_config:
echo 'PermitRootLogin yes' >>/usr/local/openssh/etc/sshd_config
echo 'PubkeyAuthentication yes' >>/usr/local/openssh/etc/sshd_config
echo 'PasswordAuthentication yes' >>/usr/local/openssh/etc/sshd_config
备份原有文件,并将新的配置复制到指定目录
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak2
mv /usr/sbin/sshd /usr/sbin/sshd.bak2
mv /usr/bin/ssh /usr/bin/ssh.bak2
mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak2
mv /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub.bak2
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
cp /backup/openssh-9.8p1/contrib/redhat/sshd.pam /etc/pam.d/sshd
cp /backup/openssh-9.8p1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod a+x /etc/pam.d/sshd
chmod a+x /etc/init.d/sshd
修改文件25行和41行:
vim /etc/init.d/sshd
25: SSHD=/usr/sbin/sshd ---> SSHD=/usr/local/openssh/sbin/sshd
41: /usr/bin/ssh-keygen -A ---> /usr/local/openssh/bin/ssh-keygen -A
重启服务务:
service sshd restart
查看版本:
ssh -V
备注:
# cp /usr/local/openssh/bin/ssh /usr/bin/ssh
# which ssh
# /usr/bin/ssh -V