赞
踩
备份配置
cp -rf /etc/ssh/ /etc/ssh.bak
cp -rf /usr/bin/openssl /usr/bin/openssl.bak
cp -rf /etc/pam.d/ /etc/pam.d.bak
cp -rf /usr/lib/systemd/system /usr/bin/system.bak
查看是否已经安装telnet
- #1查看telnet-server的 rpm 包是否安装:
- rpm -qa | grep telnet
- #2查看telnet客户端的 rpm 包是否安装:
- rpm -qa | grep telnet-server
安装telnet(该步骤是为了防止openssh升级失败导致无法连接服务器,如果不用也可以跳过)
- yum install telnet -y
- yum install xinetd
- #启动telnet服务
- systemctl start xinetd
- systemctl start telnet.socket
下载源码包
- yum install -y vim gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel zlib-devel tcp_wrappers-devel tcp_wrappers libedit-devel perl-IPC-Cmd wget tar lrzsz nano
- cd /usr/local/src/
- wget https://www.zlib.net/zlib-1.3.1.tar.gz
- wget https://www.openssl.org/source/old/3.2/openssl-3.2.1.tar.gz
- wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz
- ls #查看源码包是否都已经下载
- tar -zxvf openssh-9.8p1
- tar -zxvf openssl-3.2.1
- tar -zxvf zlib-1.3.1
4.2 安装
- #1.进入zlib-1.3.1目录
- cd /usr/local/src/zlib-1.3.1
- #2.配置
- ./configure --prefix=/usr/local/src/zlib
- #3.编译及安装(编译时间预计几分钟,视机器而定)
- make -j 4 && make test && make install
4.3 安装openssl
- #1.进入openssl-3.2.1目录
- cd /usr/local/src/openssl-3.2.1
- #2.配置
- ./config --prefix=/usr/local/src/openssl`
- #3.编译及安装(编译时间预计几分钟,视机器而定,我加了make test,花了几十分钟)
- make -j 4 && make install
- #4.配置
- mv /usr/bin/openssl /usr/bin/oldopenssl
- ln -s /usr/local/src/openssl/bin/openssl /usr/bin/openssl
- ln -s /usr/local/src/openssl/lib64/libssl.so.3 /usr/lib64/libssl.so.3
- ln -s /usr/local/src/openssl/lib64/libcrypto.so.3 /usr/lib64/libcrypto.so.3
- #5.更新动态库
- echo "/usr/local/src/openssl/lib64" >> /etc/ld.so.conf
- ldconfig
- #6.查看更新后的版本
- openssl version -v

4.4 卸载老版本OpenSSH
- #1.卸载openssh
- yum remove -y openssh
- #2.清理残余文件
- rm -rf /etc/ssh/*
4.5 安装新版本openssh9.8p1
- #1.进入openssh-9.8p1目录
- cd /usr/local/src/openssh-9.8p1
- #2.配置
- ./configure --prefix=/usr/local/src/ssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/src/openssl --with-zlib=/usr/local/src/zlib
- #3.编译及安装
- make -j 4 && make install
- #4.查看目录版本
- /usr/local/src/ssh/bin/ssh -V
- #5.复制新ssh文件
- cp -rf /usr/local/src/openssh-9.8p1/contrib/redhat/sshd.init /etc/init.d/sshd
- cp -rf /usr/local/src/openssh-9.8p1/contrib/redhat/sshd.pam /etc/pam.d/sshd
- cp -rf /usr/local/src/ssh/sbin/sshd /usr/sbin/sshd
- cp -rf /usr/local/src/ssh/bin/ssh /usr/bin/ssh
- cp -rf /usr/local/src/ssh/bin/ssh-keygen /usr/bin/ssh-keygen
- #6.允许root登录
- echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
- echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config

/etc/init.d/sshd restart
/etc/init.d/sshd status
chkconfig --add sshd
ssh -V
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。