Skip to content

Instantly share code, notes, and snippets.

@budiantoip
Last active March 7, 2025 09:54
Show Gist options
  • Save budiantoip/ad5fd340fd6e226cbf4de2d973113892 to your computer and use it in GitHub Desktop.
Save budiantoip/ad5fd340fd6e226cbf4de2d973113892 to your computer and use it in GitHub Desktop.
Upgrade OpenSSH Server on Ubuntu

References:

Step 1: Download the Latest Version

wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.9p2.tar.gz

Step 2: Remove the Existing Installation

sudo systemctl stop sshd
sudo apt-get remove openssh-server openssh-client

Step 3: Install Build Tools

sudo apt update
sudo apt install -y build-essential zlib1g-dev libssl-dev libpam0g-dev libselinux1-dev libwrap0-dev libedit-dev libbsd-dev autoconf automake libtool pkg-config wget curl git
```bash

Step 4: Build and Install OpenSSH
```bash
tar zxvf openssh-9.9p2.tar.gz
cd openssh-9.9p2
./configure
make
sudo make install
```bash

Step 5: Set Up the Service
```bash
sudo vim /etc/systemd/system/sshd.service
# Paste the following content into the file:
[Unit]
Description=OpenSSH server daemon
After=network.target

[Service]
ExecStart=/usr/local/sbin/sshd -D
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

Step 6: Reload the Daemon and Start the Service

sudo systemctl daemon-reload
sudo systemctl start sshd
sudo systemctl enable sshd

Step 7: Unmask SSH if Needed

sudo systemctl unmask ssh
sudo systemctl daemon-reload
sudo systemctl start sshd
sudo systemctl enable sshd
sudo systemctl status sshd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment