由于Centos7或red hat7系统默认的openssh版本为7.4,版本较低,如果做漏洞扫描的话经常会扫描出一堆漏洞,所以博主之前对自己的服务器的OpenSsh版本进行了升级,现在特在此记录一下升级过程
一.确认当前服务器OpenSsh版本
ssh -V

二.下载升级版本包
主要需要下载3个升级版本包,分别是:
安装的顺序也如下载顺序一致:zlib→openssl→openssh
1.zlib-1.2.13tar.gz
https://www.zlib.net/fossils/zlib-1.2.13.tar.gz
2.openssl-1.1.1t.tar.gz
https://www.openssl.org/source/openssl-1.1.1t.tar.gz
3.openssh-9.2p1.tar.gz
https://mirrors.sonic.net/pub/OpenBSD/OpenSSH/portable/openssh-9.2p1.tar.gz
三.安装版本包
1.zlib
tar zxvf zlib-1.2.13.tar.gz
cd zlib-1.2.13
./configure --prefix=/usr/local/zlib
make && make install
2.openssl
tar zxvf openssl-1.1.1t.tar.gz
cd openssl-1.1.1t
./config --prefix=/usr/local/ssl -d shared
make && make install
echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
ldconfig
3.openssh
#先卸载原先系统原装的openssh,此时记住,可以在卸载前多创建几个ssh的窗口,千万不要关闭ssh会话
yum remove openssh
#安装新的openssh
tar zxvf openssh-9.2p1.tar.gz
cd openssh-9.2p1
#这一步过程要确保configure过程正常结束
./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl
make && make install

四.配置openssh
1.配置sshd文件
[root@localhost openssh-9.2p1]# vi /usr/local/openssh/etc/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes
[root@localhost openssh-9.2p1]# cd contrib/redhat/
[root@localhost redhat]# cp sshd.init /etc/init.d/sshd
[root@localhost redhat]# chkconfig --add sshd
[root@localhost redhat]# cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
[root@localhost redhat]# cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
[root@localhost redhat]# cp /usr/local/openssh/bin/ssh /usr/bin/ssh
[root@localhost redhat]# cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
[root@localhost redhat]# cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
#启动服务
[root@localhost redhat]# systemctl start sshd.service
#设置开机启动
[root@localhost redhat]# chkconfig --add sshd
[root@localhost redhat]# chkconfig sshd on
#查看版本
[root@localhost redhat]# ssh -V
OpenSSH_9.2p1, OpenSSL 1.1.1t 7 Feb 2023
2.启动服务
systemctl start sshd.service
#设置开机启动
chkconfig --add sshd
chkconfig sshd on
#查看服务状态
systemctl status sshd.service
#查看版本
ssh -V

Comments NOTHING