This guide shows you how to view the key exchange, host key, cipher, and MAC algorithms that your SSH client and server support or are currently using. You’ll learn the exact commands to list supported algorithms, check the active session’s algorithms, and verify configuration settings—useful for security audits, debugging connection issues, or ensuring compatibility with older systems.
What You’ll Need
- A Linux system with OpenSSH installed (most distributions include it by default).
- Terminal access (local or remote).
- For checking the server’s algorithms: either root/sudo access to read the server configuration, or the ability to connect to the SSH server on port 22.
Step-by-Step
- Check the SSH client’s supported algorithms. Open a terminal and run:
ssh -Q kex— lists key exchange algorithms.ssh -Q hostkey— lists host key algorithms.ssh -Q cipher— lists symmetric ciphers.ssh -Q mac— lists message authentication codes.
These commands read the client’s built-in defaults, not the configuration file. - Check the SSH server’s supported algorithms. On the server machine, run:
sshd -T | grep -E 'kexalgorithms|ciphers|macs|hostkeyalgorithms'
This shows the effective algorithms after applying the server’s config file (usually/etc/ssh/sshd_configand included files). You need root or sudo to read the private host keys, so run withsudoif necessary. - Check the algorithms used in an active SSH session. While connected to a server, run:
ssh -v user@host(add-vfor verbose output). Look for lines starting withdebug1: KEX:,debug1: Server host key:,debug1: Cipher:, anddebug1: MAC:. These show the algorithms negotiated for that connection. - Check the client’s configuration file. The client config at
~/.ssh/configor/etc/ssh/ssh_configmay override defaults. To see what the client would actually use, run:ssh -G user@host | grep -E 'kexalgorithms|ciphers|macs|hostkeyalgorithms'
This shows the effective settings after applying all config files and command-line options. - Check the server’s configuration file directly. Open
/etc/ssh/sshd_config(and any files in/etc/ssh/sshd_config.d/) and look for lines likeKexAlgorithms,Ciphers,MACs,HostKeyAlgorithms. If a line is commented out or absent, the default for that OpenSSH version applies. - Check the running SSH server’s actual listening algorithms. Use
nmap(if installed) to scan the server’s SSH port:nmap --script ssh2-enum-algorithms -p 22 hostname
This performs a real connection and lists the algorithms the server advertises. This is useful for remote servers where you don’t have shell access.
Common Mistakes
- Confusing client and server.
ssh -Qshows the client’s built-in support, not what the server accepts. The server may have a restricted list in its config. - Forgetting that config files override defaults. The effective algorithms are the intersection of what the client and server support, after applying their respective configuration files. Always check with
ssh -Gandsshd -T. - Using
sshd -Twithout sudo. The command needs to read private host keys to list host key algorithms, so it will fail with a permission error if run as a normal user. - Assuming the verbose output shows all supported algorithms.
ssh -vonly shows the negotiated ones for that session, not the full list.
Tips
- To see a quick summary of all supported algorithms in one command, use:
for alg in kex hostkey cipher mac; do echo "$alg: $(ssh -Q $alg | tr '\n' ' ')"; done - If you’re auditing security, check for weak algorithms like
diffie-hellman-group1-sha1,ssh-rsa(for host keys),aes128-cbc, orhmac-md5. These are often disabled in modern OpenSSH versions. - To test a specific algorithm, force it with the
-ooption:ssh -o KexAlgorithms=curve25519-sha256 user@host - To see the default algorithms for your OpenSSH version, check the man pages:
man ssh_configandman sshd_configlist the defaults in the description of each option.
Troubleshooting
- Permission denied when running
sshd -T. Run withsudoor as root. If you still get an error, check that the host keys exist in/etc/ssh/. - The
ssh -Qcommand returns nothing. This can happen if OpenSSH is not installed or the version is very old. Check withssh -V. If missing, install openssh-client with your package manager. - Verbose output doesn’t show the algorithm lines. Make sure you use a single
-v(or more, like-vvv). The lines appear early in the connection handshake. If you’re already connected, you can’t see them; reconnect with-v. - nmap not found. Install nmap using your package manager (e.g.,
sudo apt install nmapon Debian/Ubuntu,sudo dnf install nmapon Fedora). - Connection fails after changing algorithms. If you edit the SSH config and then can’t connect, you may have disabled all mutually supported algorithms. Double-check that you didn’t exclude the algorithm the server uses. You can temporarily start sshd with
sshd -tto test the config syntax.
Frequently Asked Questions
What is the difference between ssh -Q and sshd -T?
ssh -Q lists the algorithms compiled into the client binary, regardless of configuration. sshd -T shows the effective algorithms the server will use after applying its configuration file.
How do I see the algorithms for the current SSH session?
Connect with ssh -v user@host and look for lines starting with debug1: KEX:, debug1: Server host key:, debug1: Cipher:, and debug1: MAC:. These show the negotiated algorithms for that connection.
Can I change the algorithms the SSH client uses?
Yes, you can specify them in ~/.ssh/config (e.g., KexAlgorithms curve25519-sha256) or use the -o command-line option. The server must also support the chosen algorithm.
Why do I see ssh-rsa in the host key list but can’t connect with it?
In OpenSSH 8.8+, the ssh-rsa signature algorithm is disabled by default because it uses SHA-1. It may still appear in the list of supported host key types, but the server refuses to use it unless you explicitly enable it with HostKeyAlgorithms +ssh-rsa in the server config.
How can I check algorithms on a remote server without logging in?
Use nmap --script ssh2-enum-algorithms -p 22 hostname. This connects to the SSH port and lists the algorithms the server advertises.
What do the algorithm names mean? For example, curve25519-sha256.
The name typically indicates the algorithm family and parameters. curve25519-sha256 is a key exchange using the Curve25519 elliptic curve and SHA-256 hashing. aes128-ctr is a symmetric cipher using AES with a 128-bit key in CTR mode. hmac-sha2-256 is a MAC using HMAC with SHA-256.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Custom Alphanumeric Passcode iPhone: How to Set
- HomePod Software Update: How to Install
- How to Shuffle Photos in Slideshow on iPhone
- Quick Look Not Working on Mac? Fixes That Work
- How to See Deleted WhatsApp Messages on iPhone
- QUIC Protocol Error in Windows 10: Fixes