Upgrade OpenSSH Server on your Ubuntu Distro manually ( tested on 22.04 LTS )
Upgrading OpenSSH server on your Ubuntu distribution manually can be necessary when the default repositories do not provide the latest version. Follow these steps to manually upgrade OpenSSH server on Ubuntu.
Step 1: Download the Latest Version
First, download the latest version of OpenSSH:
1 |
wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz |
Step 2: Remove the Existing Installation
Stop the current SSH service and remove existing OpenSSH packages:
1 2 |
sudo systemctl stop sshd sudo apt-get remove openssh-server openssh-client |
Step 3: Install Build Tools
Update your package list and install the necessary build tools:
1 2 |
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 |
Step 4: Build and Install OpenSSH
Extract the downloaded tar file and build OpenSSH:
1 2 3 4 5 |
tar zxvf openssh-9.8p1.tar.gz cd openssh-9.8p1 ./configure make sudo make install |
Step 5: Set Up the Service
Create a new systemd service file for SSH:
1 |
sudo nano /etc/systemd/system/sshd.service |
Paste the following content into the file:
1 2 3 4 5 6 7 8 9 10 11 12 |
[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 |
Save and close the file (ctrl+x y enter).
Step 6: Reload the Daemon and Start the Service
Reload the systemd daemon, start, and enable the SSH service:
1 2 3 |
sudo systemctl daemon-reload sudo systemctl start sshd sudo systemctl enable sshd |
Step 7: Unmask SSH if Needed
If you encounter issues, unmask the SSH service and repeat the previous step:
1 2 3 4 |
sudo systemctl unmask ssh sudo systemctl daemon-reload sudo systemctl start sshd sudo systemctl enable sshd |
Step 8: Check the Status
Finally, check the status of the SSH service:
1 |
sudo systemctl status sshd |
Conclusion
Manually upgrading OpenSSH server ensures you have the latest security updates and features. Make sure to regularly check for updates and apply them as needed to maintain the security of your system.