一键升级openssh至9.0p

重要前提通外网

主要应用于生产ssh安全加固

#!/bin/bash
#openssh升级脚本
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.0p1.tar.gz
yum install -y pam* zlib* openssl-devel gcc make
tar -xvf openssh-9.0p1.tar.gz
cp -r  /etc/ssh /tmp/
setenforce 0
sed -i 's/enforcing/disabled/g' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
yum -y install zlib zlib-devel openssl-devel pam-devel
cd openssh-9.0p1
./configure  --prefix=/usr --sysconfdir=/etc/ssh --with-zlib --with-pam  --without-openssl-header-check --with-ssl-dir=/usr/local/ssl --with-privsep-path=/var/lib/sshd
make
rpm -e --nodeps `rpm -qa | grep openssh`
rm -rf /etc/ssh/*
make install
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
cp -a  contrib/redhat/sshd.init /etc/init.d/sshd
chkconfig sshd on
chkconfig --add sshd
systemctl start sshd
systemctl enable sshd
systemctl restart sshd
ssh -V

你可能感兴趣的:(ssh,linux,服务器)