#!/bin/bash

yum -y install zlib zlib-devel
yum update openssh -y
yum -y install make
yum install -y openssl-devel openssl pcre-devel
yum -y install pam-devel

cp -rf /etc/ssh /etc/ssh.bak

chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key

sed -i 's/^#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/^GSSAPIAuthentication/#&/' /etc/ssh/sshd_config
sed -i 's/^GSSAPICleanupCredentials/#&/' /etc/ssh/sshd_config
sed -i 's/^UsePAM/#&/' /etc/ssh/sshd_config

sed -i 's/^Type/#&/' /lib/systemd/system/ssh.service

wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.5p1.tar.gz
tar zxf openssh-8.5p1.tar.gz

cd openssh-8.5p1
./configure --prefix=/usr --with-privsep-path=/var/empty/sshd/ \
       --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl/ \
       --with-default-path=/usr/local/bin:/bin:/usr/bin \
       --with-superuser-path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \
       --with-pam --with-selinux --disable-strip --with-md5-passwords
make
make install

systemctl daemon-reload

systemctl restart sshd

ssh -V