實驗映象
ubuntu-22.04.4-live-server-amd64.iso
# 安裝必備和常用軟體包
# 安裝相關的依賴項,如有遺漏再次安裝
apt install -y libz-dev vim gcc wget tar lrzsz nano make net-tools
# 安裝zlib
./configure --prefix=/usr/local/zlib make && make install
# 安裝openssl
./config --prefix=/usr/local/openssl make && echo $? #輸出0則代表沒有錯誤 make -j 4 install
# 覆蓋建立軟連結
ln -sf /usr/local/openssl/include/openssl /usr/include/openssl
ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -sf /usr/local/openssl/lib64/libssl.so.3 /usr/lib/x86_64-linux-gnu//libssl.so.3
ln -sf /usr/local/openssl/lib64/libcrypto.so.3 /usr/lib/x86_64-linux-gnu/libcrypto.so.3
# 驗證版本
openssl version -a
# 安裝openssh
mv /etc/ssh /etc/ssh.bak
./configure --prefix=/usr/local/openssh/ --sysconfdir=/etc/ssh/ --with-ssl-dir=/usr/local/openssl/ --with-zlib=/usr/local/zlib/ --without-openssl-header-check make -j 4 && make install
# 從安裝目錄建立軟連線到系統目錄
ln -sf /usr/local/openssh/sbin/sshd /sbin/sshd ln -sf /usr/local/openssh/bin/ssh /usr/bin/ssh ln -sf /usr/local/openssh/bin/scp /usr/bin/scp ln -sf /usr/local/openssh/bin/sftp /usr/bin/sftp ln -sf /usr/local/openssh/bin/ssh-add /usr/bin/ssh-add ln -sf /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen ln -sf /usr/local/openssh/bin/ssh-keyscan /usr/bin/ssh-keyscan
# 驗證
systemctl status sshd
sshd -V