现有的OPENSSH被检查出来有下列漏洞,没有升级,服务器很危险
OpenSSH CBC模式信息泄露漏洞(CVE-2008-5161)【原理扫描】
OpenSSH信息泄露漏洞(CVE-2020-14145)
OpenSSH 用户枚举漏洞(CVE-2018-15919)
OpenSSH 用户枚举漏洞(CVE-2018-15473)【原理扫描】
OpenSSH 安全漏洞(CVE-2017-15906)
OpenSSH 安全漏洞(CVE-2016-20012)
OpenSSH 命令注入漏洞(CVE-2020-15778)
OpenSSH 安全漏洞(CVE-2021-41617)
SSH版本信息可被获取
1、版本号查看
ssh -V
或则
rpm -qa |grep openssh
2、下载安装包
wget http://www.zlib.net/zlib-1.2.11.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.3p1.tar.gz
3、安装 zlib
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make
make install
如果出现上面这种报错界面是因为操作系统没有安装gcc ,需要先安装gcc
yum -y install rpm-build gcc make
4、安装 openssl
tar -zxvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config --prefix=/usr/local/openssl -d shared
make && make install
ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl
echo '/usr/local/openssl/lib' >> /etc/ld.so.conf
ldconfig -v
5、安装 openssh
tar -xvf openssh-8.3p1.tar.gz
cd openssh-8.3p1
./configure --prefix=/usr/local/openssh --with-ssl-dir=/usr/local/openssl --with-zlib=/usr/local/zlib
make && make install
如果出现:configure: error: *** zlib.h missing - please install first or check config.log
要执行:yum install zlib-devel
如果出现:configure: error: *** working libcrypto not found, check config.log
要执行:yum install -y openssl-devel
修改 /usr/local/openssh/etc/sshd_config 文件:
启用允许root 远程登录
找到 #PermitRootLogin prohibit-password 在下一行添加 PermitRootLogin yes,
启用公钥身份验证,将 #PubkeyAuthentication yes 注释去除,
启用隧道明文密码,将PasswordAuthentication yes注释去除,
备份 /etc/ssh 原有文件(原来没有的文件,mv 命令提示 :No such file or directory,则跳过 mv 备份),并将新的配置复制到指定目录
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
mv /usr/sbin/sshd /usr/sbin/sshd.bak
mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak
mv /usr/bin/ssh /usr/bin/ssh.bak
mv /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub.bak
cp -f /usr/local/openssh/bin/ssh /usr/bin/ssh
cp -f /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
cp -f /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
cp -f /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
cp -f /usr/local/openssh/sbin/sshd /usr/sbin/sshd
6、重启,查看版本
systemctl restart sshd
sshd -v
ssh -V
升级到openssh 9.1
./configure --prefix=/usr/local/openssh --with-ssl-dir=/usr/local/ssl --with-zlib=/usr/local/zlib --sysconfdir=/etc/ssh