[关闭]
@cdmonkey 2025-03-11T00:29:17.000000Z 字数 2703 阅读 86

OpenSSH9.9

SSH


  1. yum install -y telnet zlib zlib-devel gcc gcc-c++ make perl perl-IPC-Cmd pam pam-devel

Install OpenSSL

  1. [root@hidocker tools]# tar -zxvf openssl-3.4.1.tar.gz
  2. [root@hidocker tools]# cd openssl-3.4.1
  3. ./config --prefix=/usr/local/openssl shared zlib
  4. make
  5. make install

进行升级

  1. mv /usr/bin/openssl /usr/bin/openssl.old
  2. mv /usr/include/openssl /usr/include/openssl.old
  3. ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
  4. ln -s /usr/local/openssl/include/openssl /usr/include/openssl
  5. #
  6. echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
  7. ldconfig -v

检查版本时有报错:

  1. openssl: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory

创建两个软链:

  1. ln -s /usr/local/openssl/lib64/libssl.so.3 /usr/lib64/libssl.so.3
  2. ln -s /usr/local/openssl/lib64/libcrypto.so.3 /usr/lib64/libcrypto.so.3

再次检查版本:

  1. [root@hidocker ~]# openssl version -a
  2. OpenSSL 3.4.1 11 Feb 2025 (Library: OpenSSL 3.4.1 11 Feb 2025)
  3. built on: Tue Mar 11 05:27:39 2025 UTC
  4. platform: linux-x86_64
  5. ...

Install OpenSSH

首先进行备份。

  1. cp -a /etc/pam.d/sshd /etc/pam.d/sshd-$(date +%Y-%m-%d)
  2. cp -a /etc/pam.d/system-auth-ac /etc/pam.d/system-auth-ac-$(date +%Y-%m-%d)
  3. cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config-$(date +%Y-%m-%d)
  4. cp -a /etc/ssh/ssh_config /etc/ssh/ssh_config-$(date +%Y-%m-%d)
  5. cp -a /usr/bin/ssh-copy-id /usr/bin/ssh-copy-id-$(date +%Y-%m-%d)

先把老版本卸载掉。

  1. rpm -e --nodeps `rpm -qa | grep openssh`

安装:

  1. [root@hidocker tools]# tar -zxvf openssh-9.9p2.tar.gz
  2. [root@hidocker tools]# cd openssh-9.9p2/
  3. ./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh \
  4. --with-ssl-dir=/usr/local/openssl --with-ssl-engine \
  5. --with-pam --with-zlib --with-md5-passwords

上面的配置指令执行完后,最后将显示:

  1. PAM is enabled. You may need to install a PAM control file
  2. for sshd, otherwise password authentication may fail.
  3. Example PAM control files can be found in the contrib/
  4. subdirectory

进行编译安装:

  1. make
  2. make install

安装完成后检查版本信息:

  1. [root@hidocker ~]# /usr/local/openssh/bin/ssh -V
  2. OpenSSH_9.9p2, OpenSSL 3.4.1 11 Feb 2025

一堆软链:

  1. ln -s /usr/local/openssh/bin/scp /usr/bin/scp
  2. ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh
  3. ln -s /usr/local/openssh/bin/ssh-add /usr/bin/ssh-add
  4. ln -s /usr/local/openssh/bin/ssh-agent /usr/bin/ssh-agent
  5. ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
  6. ln -s /usr/local/openssh/bin/ssh-keyscan /usr/bin/ssh-keyscan
  7. ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshd

还有个服务启停脚本:

  1. [root@hidocker openssh-9.9p2]# cp -a contrib/redhat/sshd.init /etc/rc.d/init.d/sshd
  2. [root@hidocker openssh-9.9p2]# chmod u+x /etc/rc.d/init.d/sshd

最后还原配置:

/etc/ssh

  1. mv /etc/ssh/sshd_config /etc/ssh/sshd_config-9.9p2
  2. mv /etc/ssh/ssh_config /etc/ssh/ssh_config-9.9p2
  3. # 请确认要还原的配置文件
  4. cp -a /etc/ssh/sshd_config-2025-03-11 /etc/ssh/sshd_config
  5. cp -a /etc/ssh/ssh_config-2025-03-11 /etc/ssh/ssh_config

/etc/pam.d

  1. cp -a /etc/pam.d/sshd-2025-03-11 /etc/pam.d/sshd

这时就能够启动服务了:

  1. systemctl daemon-reload && systemctl start sshd && /sbin/chkconfig sshd on

参考内容:

https://blog.csdn.net/a33003623/article/details/144115711

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注