Codenotary Trustcenter Blog

SSH Error: Unable to Negotiate - No Matching Cipher Found

Written by blog | Mar 3, 2024 1:24:56 PM

Earlier, I tried to connect to a legacy server via SSH, only to be greeted by an error message that said "Unable to negotiate - no matching cipher found".

This dilemma is becoming increasingly common as modern operating systems clash with clashes with older OPENSSH servers.

I found myself in such a fix when attempting to access an instance of HP-UX 11, a stalwart server that had dutifully served its purpose for years. However, my Debian laptop threw me a curveball with the error message:

ssh admin@hpux.1 Unable to negotiate with hpux port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

The culprit? Incompatibility between the security protocols of my SSH client and my HP-UX server. This wasn't surprising to me because legacy systems from various vendors such as IBM, HP, and Oracle often run SSH servers that struggle to keep pace with modern security standards.

Understanding the Compatibility Issue


I tried to understand the issue and it came down to one thing. SSH, or Secure Shell, serves as the gateway to secure access to remote servers. Over time, vulnerabilities have been seen in older SSH versions and encryption algorithms. As a result of this, modern SSH clients tighten their security measures, and restrict the use of outdated methods.

Finding Solutions

As I faced these compatibility challenges, I thought of a few potential solutions that I could explore:

Allow Older Encryption Algorithms

Modern SSH clients typically disable older encryption algorithms by default. To bridge the gap between my client and a legacy server, I could consider temporarily enabling these algorithms by editing my SSH client's configuration file, either on an individual user basis (~/.ssh/config) or system-wide (/etc/ssh/ssh_config).

For example:

Host hpux
   KexAlgorithms +diffie-hellman-group1-sha1
   Ciphers +aes128-cbc 
   HostKeyAlgorithms +ssh-dss

Disable Strict Host Key Checking

In some cases, older SSH servers may utilize key types that are no longer accepted by default in modern SSH clients. While not recommended for prolonged use due to security implications, temporarily disabling strict host key checking can serve as a stopgap measure. This involved modifying my SSH configuration for the specific host:

Host oldserver.example.com
   StrictHostKeyChecking no
   UserKnownHostsFile /dev/null

(Note: Exercise caution when disabling strict host key checking, as it exposes you to potential man-in-the-middle attacks.)

Exploring Alternative Solutions

If the aforementioned approaches fail, I might encounter errors related to deprecated algorithms or insufficient key lengths. As a last resort, alternative solutions such as installing SSH version 1 or utilizing tools like PuTTY for Windows can offer a workaround.

For instance, if my SSH client rejects key lengths below 1024 bits, installing SSH version 1 can possibly resolve the issue:

apt install openssh-client-ssh1

Final Thoughts

While temporary fixes can alleviate my immediate connectivity issues, the ultimate solution for these kinds of cases lies in proactively updating SSH servers for legacy systems. Engaging with vendors to implement necessary upgrades not only ensures seamless compatibility but also improves overall security posture.