安装要求:
1、安装openssh-9.8p1,openssl版本最低是1.1.1
2、安装openssh有风险,安装请务必做好快照备份,出问题后能通过快照及时回滚。
安装步骤:
一、安装openssl-1.1.1w版本(如果当前服务器版本大于1.1.1,可以不用安装)
1、卸载当前openssl
代码语言:bash复制yum remove openssl -y
cp -rf /etc/ssl/ /tmp/ssl_bak
rm -rf /etc/ssl
2、安装
代码语言:bash复制wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
tar -zxvf openssl-1.1.1w.tar.gz
mkdir -p /opt/ssh-upgrade/openssl
cd openssl-1.1.1w
3. 编译安装:
代码语言:bash复制./config --prefix=/opt/ssh-upgrade/openssl/ --openssldir=/opt/ssh-upgrade/openssl/ shared
make
make install
4. 创建软连接:
代码语言:bash复制ln -s /opt/ssh-upgrade/openssl/bin/openssl /usr/bin/openssl
ln -s /opt/ssh-upgrade/openssl/include/openssl /usr/include/openssl
5. 更新动态库:
代码语言:bash复制echo "/opt/ssh-upgrade/openssl/lib" >> /etc/ld.so.conf.d/ssh-upgrade.conf
ldconfig
6. 查看当前版本:
代码语言:bash复制openssl version
二、安装openssh
1、卸载当前版本
代码语言:bash复制cp -rf /etc/ssh/ /tmp/
yum remove openssh -y
2、安装
代码语言:bash复制cd ~
wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz
tar zxf openssh-9.8p1.tar.gz
mkdir -p /opt/ssh-upgrade/openssh/
cd openssh-9.8p1
3. 编译安装:
代码语言:txt复制./configure --prefix=/opt/ssh-upgrade/openssh/ --sysconfdir=/opt/ssh-upgrade/openssh/ssh/ --with-openssl-includes=/opt/ssh-upgrade/openssl/include/ --with-ssl-dir=/opt/ssh-upgrade/openssl/ --with-zlib=/opt/ssh-upgrade/zlib/ --with-md5-passwords --without-openssl-header-check
make
make install
4. 创建软链接
代码语言:bash复制ln -s /opt/ssh-upgrade/openssh/sbin/sshd /usr/sbin/sshd
ln -s /opt/ssh-upgrade/openssh/bin/ssh /usr/bin/ssh
ln -s /opt/ssh-upgrade/openssh/bin/ssh-add /usr/bin/ssh-add
ln -s /opt/ssh-upgrade/openssh/bin/ssh-agent /usr/bin/ssh-agent
ln -s /opt/ssh-upgrade/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
ln -s /opt/ssh-upgrade/openssh/bin/ssh-keyscan /usr/bin/ssh-keyscan
5. 修改配置文件
代码语言:bash复制vim /opt/ssh-upgrade/openssh/ssh/sshd_config
#将下面参数修改
PermitRootLogin yes
PasswordAuthentication yes
6. 拷贝openssh/ssh/目录下的文件到/etc/ssh目录下
代码语言:bash复制cp -rf /opt/ssh-upgrade/openssh/ssh/* /etc/ssh/
7. 设置启动脚本
代码语言:bash复制cp -rf contrib/redhat/sshd.init /etc/init.d/sshd
8. 将sshd添加到系统中
代码语言:bash复制chkconfig --add sshd
9. 设置开机自启动
代码语言:bash复制chkconfig sshd on
10. 启动服务
代码语言:bash复制systemctl restart sshd
systemctl status sshd
11. 启动完成,最后查看版本:
代码语言:bash复制ssh -V