环境说明
操作系统: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
# 准备编译环境
apt-get install libpam0g-dev gcc zlib1g-dev libssl-dev make -y
# 【openssh】
# 下载
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-8.9p1.tar.gz
tar xf openssh-8.9p1.tar.gz
cd openssh-8.9p1
# 隐藏版本号
sed -i 's/OpenSSH_8.9/OpenSSH_899/g' version.h
# 编译安装
./configure --prefix=/usr/local/myssh_8.9p1 \
--sysconfdir=/usr/local/myssh_8.9p1/ssh \
--with-privsep-user=sshd --with-zlib \
--with-pam \
--without-openssl-header-check
make && make install
# 备份openssh
mv /usr/sbin/sshd /usr/sbin/sshd.bak_`date '+%Y-%m-%-d_%H:%M:%S'`
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak_`date '+%Y-%m-%-d_%H:%M:%S'`
# 创建软连接
ln -s /usr/local/myssh_8.9p1/sbin/sshd /usr/sbin/sshd
ln -s /usr/local/myssh_8.9p1/ssh/sshd_config /etc/ssh/sshd_config
# 避开安全扫描
echo "Protocol 2" >> /usr/local/myssh_8.9p1/ssh/sshd_config
echo "Banner /etc/ssh_banner" >> /usr/local/myssh_8.9p1/ssh/sshd_config
systemctl restart sshd