前提要求

  • A C compiler
  • A working installation of zlib

编译安装

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# download
export OpenSSH_version="9.0p1"
cd /usr/local/src/
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/DJM-GPG-KEY.asc
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-${OpenSSH_version}.tar.gz.asc
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-${OpenSSH_version}.tar.gz
gpg --keyid-format long --list-options show-keyring DJM-GPG-KEY.asc
gpg --import DJM-GPG-KEY.asc
gpg --verify openssh-${OpenSSH_version}.tar.gz.asc openssh-${OpenSSH_version}.tar.gz
tar xf openssh-${OpenSSH_version}.tar.gz
cd openssh-${OpenSSH_version}

./configure \
--prefix=/opt/openssh \
--with-zlib=/opt/zlib \
--with-openssl=/opt/openssl \
--with-libs=/opt/openssl/lib

make
make install


which ssh
/usr/bin/ssh -V

cp /usr/lib/systemd/system/sshd.service{,.bak}

systemctl disable sshd --now


systemctl daemon-reload
systemctl enable sshd --now
systemctl status sshd
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# download
export OpenSSH_version="9.8p1"
cd /usr/local/src/
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-${OpenSSH_version}.tar.gz
tar xf openssh-${OpenSSH_version}.tar.gz
cd openssh-${OpenSSH_version}

cat INSTALL
# Zlib 1.1.4 or 1.2.1.2 or greater (earlier 1.2.x versions have problems): https://zlib.net/
# OpenSSL (https://www.openssl.org) 1.1.1 or greater


./configure \
--prefix=/opt/openssh \
--with-zlib=/opt/zlib \
--with-openssl=/opt/openssl \
--with-libs=/opt/openssl/lib

make
make install


which ssh
/usr/bin/ssh -V

cp /usr/lib/systemd/system/sshd.service{,.bak}

systemctl disable sshd --now
systemctl daemon-reload
systemctl enable sshd --now
systemctl status sshd