深圳南山区网站建设,网络营销的有形层,怎么看网站备案,宿迁网站建设公司一、背景#xff1a;
公司安全扫描到主机的OpenSSH安全漏洞#xff0c;由于是虚拟机只能由自己修复#xff0c;很多OpenSSH的漏洞厂商都没有提供补丁#xff0c;只能通过禁用scp或者端口的方式临时解决#xff0c;但是后面使用就不方便了#xff0c;而且也不安全#x…
一、背景
公司安全扫描到主机的OpenSSH安全漏洞由于是虚拟机只能由自己修复很多OpenSSH的漏洞厂商都没有提供补丁只能通过禁用scp或者端口的方式临时解决但是后面使用就不方便了而且也不安全所以直接将OpenSSH升级到现在的最高版本openssh-9.3p2ssl升级到1.1.1。 二、准备工作
升级OpenSSH是有风险的失败会导致不能通过SSH连接到主机所以最好先按照telnet的相关工具通过telnet连接主机进行SSH升级操作因为此次操作的是虚拟机跟公司的机房老师沟通即使升级失败他们也是可以连接上主机的所有我就没再按照telnet的相关组件直接通过SSH连接到主机进行的升级。升级前可以先看下报错处理章节方便安装过程中有问题解决。
升级SSH需要先查看gcc、pcre、zlib perl是否安装使用以下命令可以查看
gcc --version、rpm -qa pcre、yum list installed | grep zlib*、perl -version。查看SSH版本 ssh -V, 查看ssl版本openssl version gcc包没有的请参考这篇文章https://blog.51cto.com/u_15064655/4818120
perl没有的
下载地址https://www.cpan.org/src/5.0/perl-5.34.0.tar.gz将包上传到服务器上然后执行一下命令 tar -xzf perl-5.34.0.tar.gz cd perl-5.34.0
./Configure -des -Dprefix$HOME/localperl
make
make test
make install
注意
1、通过SSH连接主机升级时不要关闭SSH连接再升级过程中关闭了以后可能就连不上了
2、SSH升级依赖于SSL对SSL的版本有要求要先按照SSL再按照SSH
三、开始安装
1、下载openssl、openssh、zlib包
下载openssl https://www.openssl.org/source/openssl-1.1.1t.tar.gz 下载openssh https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.3p2.tar.gz 下载zlib http://www.zlib.net/zlib-1.2.13.tar.gz
按照顺序是zlib库- openssl - openssh的顺序安装
2、安装zlib
tar -zxvf zlib-1.2.13.tar.gz -C /usr/local/src
cd zlib-1.2.13 ./configure --prefix/usr/local/zlib ?make?-j 4??make?install 3、安装ssl
tar -zxvf openssl-1.1.1t.tar.gz -C /usr/local/src/ cd /usr/local/src/openssl-1.1.1t
./config --prefix/usr/local/ssl -d shared #编译时可能会报错请看错误模块
make -j 4 make install echo /usr/local/ssl/lib /etc/ld.so.conf
ldconfig -v
/usr/local/ssl/bin/openssl version -a # 查询这个目录下openssl版本已是1.1.1p
4、安装ssh
tar -zxvf openssh-9.3p1.tar.gz -C /usr/local/src/
先备份mv /etc/ssh /etc/ssh.bak cd /usr/local/src/openssh-9.3p2
#指定ssl和zlib安装位置 ./configure --prefix/usr/local/openssh --sysconfdir/etc/ssh --with-ssl-dir/usr/local/ssl --with-zlib/usr/local/zlib
make -j 4 make install
#修改配置文件sshd_config文件修改
echo X11Forwarding yes /etc/ssh/sshd_config echo X11UseLocalhost no /etc/ssh/sshd_config echo XAuthLocation /usr/bin/xauth /etc/ssh/sshd_config echo UseDNS no /etc/ssh/sshd_config echo PermitRootLogin yes /etc/ssh/sshd_config echo PubkeyAuthentication yes /etc/ssh/sshd_config echo PasswordAuthentication yes /etc/ssh/sshd_config
#备份 /etc/ssh 原有文件并将新的配置复制到指定目录
mv /usr/sbin/sshd /usr/sbin/sshd.bak cp -rf /usr/local/openssh/sbin/sshd /usr/sbin/sshd mv /usr/bin/ssh /usr/bin/ssh.bak cp -rf /usr/local/openssh/bin/ssh /usr/bin/ssh mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak cp -rf /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen 安装完成查看版本ssh -V 5、重启sshd服务
systemctl restart sshd
systemctl status sshd
四、报错处理
1、执行ssl的./config --prefix/usr/local/ssl -d shared编译时报错
Operating system: x86_64-whatever-linux2 You need Perl 5.
你需要安装perl-5.34.0.tar.gz
下载https://www.cpan.org/src/5.0/perl-5.34.0.tar.gz
tar -xzf perl-5.34.0.tar.gz cd perl-5.34.0 ./Configure -des -Dprefix$HOME/localperl make make test make install
2、ssl 执行 make -j 4 make install报错 sh: pod2html: command not found 没找到原因但是暂时没找到有什么影响测试ssl是正常的。
3、重启ssh服务报错
Job for sshd.service failed because the control process exited with error code. See systemctl status sshd.service and journalctl -xe for details. 使用/usr/sbin/sshd -T查看 是/etc/ssh/ssh_host_ed25519_key这个文件的权限太大了去所在目录下执行 chmod 600 ssh_host_ed25519_key 命令修改文件权限重启可能还报错再用-T看下还有其他的文件权限太大。 chmod 600 ssh_host_rsa_key、chmod 600 ssh_host_ecdsa_key、 chmod 600 ssh_host_ed25519_key基本上这三个。 4、重启报错Job for sshd.service failed because the control process exited with error code. See systemctl status sshd.service and journalctl -xe for details.
用sshd -t看到报错信息为
/etc/ssh/sshd_config line 80: Unsupported option GSSAPICleanupCredentials
/etc/ssh/sshd_config line 96: Unsupported option UsePAM vi /etc/ssh/sshd_config 把#GSSAPIAuthentication yes 、#GSSAPICleanupCredentials no 把这两个禁掉 #UsePAM no也禁掉