How to Safely Upgrade OpenSSH 9.9p2 on AWS: A Step-by-Step Guide #PerSourcePenalties #CVE-2025-26465 & CVE-2025-26466

OpenSSH is a critical component for managing remote servers securely. Recently, vulnerabilities CVE-2025-26465 and CVE-2025-26466 were discovered in older OpenSSH versions, making it essential to upgrade to version 9.9p2. However, modifying SSH on a live production server can be risky.

In this guide, we will:

Why Upgrade OpenSSH in a Production Environment?

Upgrading OpenSSH is crucial for:

Pre-Update Precautions (Before Making SSH Changes)

Since modifying SSH can lock you out of your server, follow these steps carefully.

Step 1: Install AWS CLI and Session Manager Plugin on Your Local System

SSM (AWS Systems Manager) allows remote access to instances without SSH. Install and configure it first.

sudo apt install awscli -y

curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb"

sudo dpkg -i session-manager-plugin.deb


Step 2: Attach the Correct IAM Role to Your Instance

Your EC2 instance needs the AmazonSSMManagedInstanceCore policy to work with SSM.

Step 3: Verify if the SSM Agent is Installed

Check if the AWS Systems Manager Agent (SSM Agent) is running:

sudo systemctl status amazon-ssm-agent

amazon-ssm-agent --version


If the agent is not installed, install it using the following:

sudo snap install amazon-ssm-agent

sudo snap restart amazon-ssm-agent


Step 4: Connect to Your Instance Using SSM (Instead of SSH)

If SSH fails after the upgrade, use AWS SSM to access the server:

aws ssm start-session --target i-xxxxxxxxxxxxxxxxx --profile lalatendu-own-aws-profile (Please note if you have multiple aws profile then you need to mention profile name)


Why Use AWS SSM Instead of SSH?


How to Upgrade OpenSSH to 9.9p2 on AWS

Once you've set up an alternative access method, proceed with the OpenSSH upgrade.

Step 1: Check Current OpenSSH Version

ssh -V


If it is below 9.9p2, continue with the upgrade.

Step 2: Download and Compile OpenSSH 9.9p2 from Source

cd /usr/local/src

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

tar -xvzf openssh-9.9p2.tar.gz

cd openssh-9.9p2


Step 3: Install Required Dependencies

sudo apt update && sudo apt install -y build-essential zlib1g-dev libssl-dev libpam0g-dev libselinux1-dev


Step 4: Configure and Install OpenSSH

./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam

make -j$(nproc)

sudo make install

ssh -V


Step 5: Backup Existing SSH Configuration and Restart SSH

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

sudo systemctl restart ssh


What is PerSourcePenalties?

PerSourcePenalties is an OpenSSH daemon (sshd) configuration option that applies penalties to sources (IP addresses) exhibiting abusive behavior. When enabled, OpenSSH delays response times for repeated failed authentication attempts from the same source, making brute-force attacks significantly less effective.

Why is PerSourcePenalties Important?

How to Enable PerSourcePenalties in OpenSSH 9.9+

Step 1: Verify OpenSSH Version

Ensure that your system is running OpenSSH 9.9p1 or later:

ssh -V


Expected output:

OpenSSH_9.9p2, OpenSSL x.y.z


If your version is older, you will need to upgrade OpenSSH.

Step 2: Enable PerSourcePenalties

Edit the SSH daemon configuration file:

sudo nano /etc/ssh/sshd_config


Add or modify the following line:

PerSourcePenalties yes


Step 3: Restart the SSH Service

For changes to take effect, restart the SSH daemon:

sudo systemctl restart ssh


Step 4: Verify That PerSourcePenalties is Active

Run the following command:

sshd -T | grep persourcepenalties


Expected output:

persourcepenalties yes


How PerSourcePenalties Works

When enabled, OpenSSH will gradually introduce delays for authentication attempts originating from the same IP address if they continuously fail. Instead of immediately blocking the IP, OpenSSH will make successive attempts take longer to process, making brute-force attacks inefficient.

Considerations for Production Environments

Final Testing and Verification

Conclusion

Upgrading OpenSSH on AWS is crucial for security but should be approached with caution. Implementing AWS Systems Manager (SSM) ensures access to your instance even if SSH fails, preventing potential lockouts. Always test upgrades on a non-production environment before applying them to critical systems.

Additionally, the PerSourcePenalties feature in OpenSSH 9.9+ enhances security by slowing down repeated failed login attempts, effectively mitigating brute-force attacks. As a built-in solution, it strengthens SSH access without relying on external tools. For system administrators and organizations aiming to secure remote access, enabling this feature is a simple yet effective step toward improving security.

What is PerSourcePenalties in OpenSSH?

How to enable PerSourcePenalties in OpenSSH?

Does PerSourcePenalties block brute-force attacks?

How to secure SSH without using fail2ban?

OpenSSH 9.9 security improvements and features.

How to upgrade OpenSSH 9.9p2 on AWS?

How to fix OpenSSH vulnerabilities CVE-2025-26465 & CVE-2025-26466?

How to enable AWS SSM for remote access?

Best practices for upgrading OpenSSH in production?

How to use AWS Systems Manager instead of SSH?

Top SEO Keyword-Related Hashtags

#AWS #OpenSSH #CyberSecurity #DevOps #Linux #AWS_SSM #CloudSecurity #SSH #SystemAdministration #AWSCLI #EC2 #ServerManagement #SSM#OpenSSH #CyberSecurity #SSH #BruteForceProtection #LinuxSecurity #SystemAdministration #DevSecOps #SSHSecurity #PerSourcePenalties #CloudSecurity#CVE-2025-26465 #CVE-2025-26466