环境说明

操作系统:Ubuntu 20.04.4 LTS
内核版本:5.4.0-104-generic
openssh版本:OpenSSH_8.2p1
openssl版本:OpenSSL 1.1.1f 31 Mar 2020

升级openssh至8.9

  1. # 准备编译环境
  2. apt-get install libpam0g-dev gcc zlib1g-dev libssl-dev make -y
  3. # 【openssh】
  4. # 下载
  5. wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-8.9p1.tar.gz
  6. tar xf openssh-8.9p1.tar.gz
  7. cd openssh-8.9p1
  8. # 隐藏版本号
  9. sed -i 's/OpenSSH_8.9/OpenSSH_899/g' version.h
  10. # 编译安装
  11. ./configure --prefix=/usr/local/myssh_8.9p1 \
  12. --sysconfdir=/usr/local/myssh_8.9p1/ssh \
  13. --with-privsep-user=sshd --with-zlib \
  14. --with-pam \
  15. --without-openssl-header-check
  16. make && make install
  17. # 备份openssh
  18. mv /usr/sbin/sshd /usr/sbin/sshd.bak_`date '+%Y-%m-%-d_%H:%M:%S'`
  19. mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak_`date '+%Y-%m-%-d_%H:%M:%S'`
  20. # 创建软连接
  21. ln -s /usr/local/myssh_8.9p1/sbin/sshd /usr/sbin/sshd
  22. ln -s /usr/local/myssh_8.9p1/ssh/sshd_config /etc/ssh/sshd_config
  23. # 避开安全扫描
  24. echo "Protocol 2" >> /usr/local/myssh_8.9p1/ssh/sshd_config
  25. echo "Banner /etc/ssh_banner" >> /usr/local/myssh_8.9p1/ssh/sshd_config
  26. systemctl restart sshd