1查看版本
[root@VM-0-15-centos ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[root@VM-0-15-centos ~]#
[root@VM-0-15-centos ~]# rpm -qa| grep openssh
openssh-7.4p1-21.el7.x86_64
openssh-clients-7.4p1-21.el7.x86_64
openssh-server-7.4p1-21.el7.x86_64
[root@VM-0-15-centos ~]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
2安装openssl 和zalib
tar zxvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w/
./config --prefix=/usr/local/ssl
make
make install
echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
ldconfig -v
[root@VM-0-15-centos ~]# /usr/local/ssl/bin/openssl version
OpenSSL 1.1.1w 11 Sep 2023
#zlib
tar xvf zlib-1.3.tar.xz
cd zlib-1.3/
./configure --prefix=/usr/local/zlib
make
make install
3 下载openssh 和安装
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.7p1.tar.gz .
[root@VM-0-15-centos ~]# rpm -qa| grep openssh
openssh-7.4p1-21.el7.x86_64
openssh-clients-7.4p1-21.el7.x86_64
openssh-server-7.4p1-21.el7.x86_64
[root@VM-0-15-centos ~]# rpm -e openssh-7.4p1-21.el7.x86_64 --nodeps
[root@VM-0-15-centos ~]# rpm -e openssh-clients-7.4p1-21.el7.x86_64 --nodeps
[root@VM-0-15-centos ~]# rpm -e openssh-server-7.4p1-21.el7.x86_64 --nodeps
warning: /etc/ssh/sshd_config saved as /etc/ssh/sshd_config.rpmsave
#再次查询确认
[root@VM-0-15-centos ~]# rpm -qa| grep openssh
tar zxvf openssh-9.7p1.tar.gz
cd openssh-9.7p1/
./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl
make
make install
sed -i 's/^#UseDNS.*/UseDNS no/' /usr/local/openssh/etc/sshd_config
sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /usr/local/openssh/etc/sshd_config
sed -i 's/^#PubkeyAuthentication.*/PubkeyAuthentication yes/' /usr/local/openssh/etc/sshd_config
sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication yes/' /usr/local/openssh/etc/sshd_config
vim /usr/local/openssh/etc/sshd_config#底部增加
HostKeyAlgorithms +ssh-rsa,ssh-dss
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1
#拷贝到环境
cp /usr/local/openssh/sbin/sshd /usr/sbin/
cp /usr/local/openssh/bin/ssh /usr/bin/
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/
cp /usr/local/openssh/bin/sftp /usr/bin/
cp /usr/local/openssh/bin/scp /usr/bin/
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
#启动
chmod u+x /etc/init.d/sshd
/etc/init.d/sshd start
#查看
[root@VM-0-15-centos ~]# ssh -V
OpenSSH_9.7p1, OpenSSL 1.1.1w 11 Sep 2023