CentOS7.9操作系统openssh升级
CentOS7.9操作系统升级openssh版本
服务器环境: 操作系统:CentOS 7.9 当前版本:OpenSSH 7.4p1,目标版本OpenSSH9.9p2
一、准备工作
为防止升级过程中意外断开,导致无法连接服务器。我们安装telnet-server作为备用连接。
(一) 启用telnet-server服务
1. 安装telnet-server和xinetd包
yum install telnet-server xinetd
2. 编辑/etc/securetty配置
在文件末尾追加以下两行:
pts/0
pts/1
3. 启动telnet-server 和xinetd服务
systemctl start telnet.socket
systemctl start xinetd
(二) 测试是否可以正常连接
Windows+R打开运行窗口。输入cmd。回车打开命令提示符窗口。输入telnet x.x.x.x
回车。用root权限登陆。确认连接正常再往下进行。
如果你的Windows系统未安装telnet客户端。则需要在打开或者关闭Windows功能中安装。或者直接使用putty,Connection Type选择telnet协议。
二、升级openssl版本
1. 下载源码包
wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
2. 安装openssl 1.1.1w
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
make
make install
3. 添加所缺函数库
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
4. 更新函数库
ldconfig -v
5. 检查版本
/usr/local/openssl/bin/openssl version
三、安装openssh9.9p2
1. 卸载openssh
yum remove openssh-clients openssh-server
2. 依赖安装
yum install zlib-devel pam-devel
cd /root/openssh-9.9p2
3. 配置、编译、安装
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib --without-hardening
make
make install
4. 启动文件配置
cp ./contrib/redhat/sshd.init /etc/init.d/sshd 修改以下配置为我们安装到的目录
SSHD=/usr/local/openssh/sbin/sshd
/usr/local/openssh/bin/ssh-keygen -A
5. 重新加载配置
systemctl daemon-reload
最后我们先不要断开当前ssh连接,用新建连接测试是否能够正常建立ssh连接。