Upgrade OpenSSH Version on Kylin V10

OpenSSH_8.2p1 to OpenSSH_10.0p2

[root@host1 ~]# cat /etc/os-release 
NAME="Kylin Linux Advanced Server"
VERSION="V10 (Tercel)"
ID="kylin"
VERSION_ID="V10"
PRETTY_NAME="Kylin Linux Advanced Server V10 (Tercel)"
ANSI_COLOR="0;31"

[root@host1 ~]# uname -a
Linux host1.novalocal 4.19.90-23.48.v2101.ky10.aarch64 #1 SMP Tue Jun 4 18:45:32 CST 2024 aarch64 aarch64 aarch64 GNU/Linux

[root@host1 ~]# sshd -V
OpenSSH_8.2p1, OpenSSL 1.1.1f 31 Mar 2020
  1. Download openssh/openssl/zlib package to openssh directory.

openssh:https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-10.0p1.tar.gz
openssl:https://www.openssl.org/source/openssl-3.3.1.tar.gz
zlib:https://www.zlib.net/zlib-1.3.1.tar.gz

[root@host1 ~]# mkdir openssh
[root@host1 ~]# ls openssh
openssh-10.0p1.tar.gz openssl-3.3.1.tar.gz zlib-1.3.1.tar.gz
  1. Create an install.sh script.
#!/bin/bash

check() {
if [ "$?" != "0" ]
then
echo -e "\e[31m Install OpenSSH Failed!!! \e[0m"
exit 6
fi
}

echo -e "\033[32m Begain Installing. \033[0m"
tar -zxf openssh-10.0p1.tar.gz
tar -zxf openssl-3.3.1.tar.gz
tar -zxf zlib-1.3.1.tar.gz

cd zlib-1.3.1/
./configure --prefix=/usr/local/zlib
check

make && make install
check

cd ../openssl-3.3.1/
./configure --prefix=/usr/local/openssl
check

make -j 4 && make install
check

echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig
ldconfig -p | grep ssl
echo "export PATH=/usr/local/openssl/bin:$PATH" >> /etc/profile
source /etc/profile
check

mv /etc/ssh /etc/ssh_bak
mv /usr/bin/ssh /usr/bin/ssh_bak
mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen_bak
mv /usr/sbin/sshd /usr/sbin/sshd_bak
cp -a /etc/pam.d/sshd /etc/pam.d/sshd_bak

cd ../openssh-10.0p1/
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/openssl --with-zlib=/usr/local/zlib
check

make && make install
check

cp -a /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp -a /usr/local/openssh/bin/ssh /usr/bin/ssh
cp -a /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
cp -a /root/openssh/openssh-10.0p1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd

echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config

cat > /etc/systemd/system/sshd.service << 'EOF'
[Unit]
Description=OpenSSH Server
After=network.target

[Service]
ExecStart=/usr/local/openssh/sbin/sshd -f /etc/ssh/sshd_config
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

chmod +x /etc/systemd/system/sshd.service

systemctl daemon-reload
systemctl enable sshd
systemctl restart sshd

echo -e "\033[32m The new OpenSSH Version: \033[0m"
sshd -V
  1. Run the install.sh script.
[root@host1 ~]# cd openssh
[root@host1 openssh]# ls
install.sh openssh-10.0p1.tar.gz openssl-3.3.1.tar.gz zlib-1.3.1.tar.gz

[root@host1 openssh]# bash install.sh
  1. Check.
[root@host1 ~]# sshd -V
OpenSSH_10.0p2, OpenSSL 3.3.1 4 Jun 2024