Linux Upgrade OpenSSH

download source

1
2
3
4
5
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-10.0p2.tar.gz
wget https://github.com/openssl/openssl/releases/download/openssl-3.5.0/openssl-3.5.0.tar.gz

tar -xf openssh-10.0p2.tar.gz
tar -xf openssl-3.5.0.tar.gz

build and install openssl

1
2
3
4
5
cd openssl-3.5.0
./config shared --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
make && sudo make install
sudo cp /usr/local/openssl/bin/openssl /usr/local/openssl
openssl version

build and install openssh

First, uninstall the remaining openssh

1
sudo apt remove --purge ssh openssh-client openssh-server openssh-sftp-server

install openssh dependency for ubuntu

1
sudo apt install  zlib1g-dev libpam0g-dev libkrb5-dev libedit-dev -y
1
2
3
4
5
6
7
8
9
10
11
cd openssh-10.0p2
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-kerberos5 --with-libedit --with-pam --with-gssapi --with-zlib --with-ssl-dir=/usr/local/openssl --with-privsep-path=/var/lib/sshd
make && sudo make install
sudo ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshd
sudo ln -s /usr/local/openssh/bin/scp /usr/bin/
sudo ln -s /usr/local/openssh/bin/sftp /usr/bin/
sudo ln -s /usr/local/openssh/bin/ssh /usr/bin/
sudo ln -s /usr/local/openssh/bin/ssh-add /usr/bin/
sudo ln -s /usr/local/openssh/bin/ssh-agent /usr/bin/
sudo ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/
sudo ln -s /usr/local/openssh/bin/ssh-keyscan /usr/bin/

openssh service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[Unit]
Description=OpenBSD Secure Shell server
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target
Alias=sshd.service

Linux Upgrade OpenSSH
https://jgq12138.github.io/2025/06/24/Linux/LinuxUpgradeOpenSSH/
作者
JGQ12138
发布于
2025年6月24日
许可协议