SSH Guru Blog.
← SSH Guru Blog
Browser SSH
·7 min read

Why SSH Security Still Matters When the Network Lies

ssh securityhost keyskey authenticationnetwork attacks
Spacious airport terminal window reflections create a geometric and architectural effect.
Photo: Rishi on Pexels

A report from The420.in describes attackers hijacking hundreds of Tor exit nodes to intercept SSH credentials and mail traffic. The details are still emerging, but the core lesson for ssh security is already clear: the network path between you and your server can be hostile, and you cannot rely on the transport layer to protect you.

SSH was designed for this. Two mechanisms, host-key verification and public-key authentication, are what keep the session trustworthy even when the path is actively malicious. They are not new features. They are the foundation. But they only work if you actually use them and if your client enforces them.

The threat model: the path is hostile

When you open an SSH connection, your packets traverse routers, switches, ISPs, carrier hotels, and sometimes exit nodes you do not control. Any of those hops can be compromised. An attacker who controls a hop can:

  • Intercept and log everything sent in cleartext (passwords, session output, forwarded agent sockets).
  • Perform a machine-in-the-middle attack, presenting a fake host key and proxying the session to the real server.
  • Inject keystrokes or commands into an established session if encryption keys are weak or negotiated poorly.

TLS has certificate authorities to solve the identity problem. SSH has a simpler, harsher model: trust on first use (TOFU) combined with explicit host-key pinning. If the host key changes, the client screams. That scream is your only reliable signal that the path has been tampered with.

Host-key verification: what it actually does

Every SSH server has a persistent identity key pair (Ed25519, RSA, ECDSA). The public half is the host key. When you connect for the first time, the client shows you the fingerprint and asks you to verify it. If you accept, the client stores that key in ~/.ssh/known_hosts. On subsequent connections, the client compares the presented key to the stored one. A mismatch aborts the connection.

This defeats a classic machine-in-the-middle attack. The attacker can terminate your TCP connection and proxy a new one to the real server, but they cannot forge the real server's host key without the private half. They can present their own key, but your client will reject it because it does not match the pinned value.

The failure mode is human: users see the warning and type yes anyway. The warning exists because the key changed, maybe the server was reinstalled, maybe the key was rotated, maybe the path is hostile. Treating the warning as noise defeats the entire mechanism.

Pinning in practice

  • First connection: verify the fingerprint out of band. Compare it to the output of ssh-keyscan run from a trusted host, or to the fingerprint printed on the console during server provisioning, or to a value stored in your configuration management.
  • Subsequent connections: let the client enforce the match. Do not delete known_hosts entries to "fix" a warning. Investigate the change.
  • Key rotation: when you legitimately rotate host keys, distribute the new fingerprints through a trusted channel (configuration management, a signed artifact, a separate authenticated API) before the switch.

Our browser client pins host keys in the browser's encrypted vault. On first connect you see the fingerprint. On reconnect, a mismatch blocks the session and surfaces a warning you cannot dismiss with a click. The vault is encrypted with your passphrase; we never see the keys and cannot reset them.

Key-based authentication: removing the secret from the wire

Password authentication sends a secret over the encrypted channel. If the channel is compromised at the endpoint (keylogger, malicious jump host, compromised client machine), the password is captured. If the host key was not verified, the attacker terminates the encryption at their proxy, decrypts the password, and re-encrypts toward the real server.

Public-key authentication changes the equation. The private key never leaves your machine. The client proves possession of the private key by signing a session-specific challenge from the server. The signature is useless to an attacker because it is bound to that session's ephemeral keys. Replay does not work. A machine-in-the-middle that does not have the server's host private key cannot complete the handshake. A machine-in-the-middle that does have the host private key has already compromised the server, a different problem.

Key-based auth also eliminates brute-force password guessing against the server. The server only accepts signatures verified against authorized public keys. No password database to leak, no guessable secrets.

What "key-based" means for your workflow

  • Generate an Ed25519 key per device: ssh-keygen -t ed25519 -C "laptop-2024".
  • Add the public key to ~/.ssh/authorized_keys on each target server.
  • Disable password authentication in sshd_config: PasswordAuthentication no, ChallengeResponseAuthentication no, UsePAM no (if you don't need PAM for other factors).
  • Use an SSH agent with a reasonable timeout so you are not typing a passphrase on every command, but the key is not resident in memory indefinitely.
  • For browser-based access, our client generates the key pair in the browser, encrypts it with Argon2id + AES-256-GCM under your vault passphrase, and never uploads the plaintext. The private key stays in the browser's memory only while the vault is unlocked.

The Tor exit-node case: what changes

The reported attack targets traffic exiting Tor. Tor encrypts your traffic to the exit node, but the exit node sees the plaintext destined for the final server. If that plaintext is an SSH session with password authentication and no host-key verification, the exit node operator (or someone who compromised the exit node) sees the password and can impersonate you to the real server.

If you use host-key verification, the exit node cannot present a valid host key for your server. The client aborts.

If you use key-based authentication, the exit node sees a public-key handshake. They learn your username and the public key you offered. They do not learn the private key. They cannot replay the authentication.

If you use both, the exit node learns almost nothing useful: the server's host key (public), your username, your client's public key, and encrypted noise. They cannot inject commands, capture credentials, or persist access.

This is not theoretical. It is the designed threat model of SSH.

Common ways people break the model

  1. Accepting unknown host keys automatically. StrictHostKeyChecking=no or ssh-keyscan >> known_hosts without verification. This turns TOFU into trust-on-always, which is no trust at all.
  2. Using shared accounts with password auth. One leaked password compromises every session from every origin.
  3. Forwarding agents through untrusted hosts. ForwardAgent yes on a jump host you do not control lets that host use your keys for its own connections.
  4. Ignoring key rotation. A server reinstall generates new host keys. If you delete the old entry and accept the new one without verification, you have no continuity of identity.
  5. Storing private keys on shared filesystems or in container images. The key is only as secret as the weakest place it resides.

Hardening checklist

  • Enforce host-key verification everywhere. Set StrictHostKeyChecking=yes and UserKnownHostsFile=~/.ssh/known_hosts in your SSH config. Do not use StrictHostKeyChecking=accept-new for production hosts; it accepts the first key it sees.
  • Use Ed25519 host keys and user keys. They are faster, smaller, and not vulnerable to the side-channel issues that plague older curves.
  • Disable password and keyboard-interactive auth on internet-facing servers.
  • Pin host keys in automation. Ansible, Terraform, and CI runners should have the expected host keys pre-populated in their known_hosts files, not gathered on first run.
  • Audit known_hosts periodically. Look for duplicate IPs with different keys, or hostnames with multiple key types where you only expect one.
  • Use certificates for large fleets. SSH certificates (not X.509) let a CA sign host keys and user keys with short lifetimes. The client trusts the CA public key once, then validates every certificate. This scales verification without manual TOFU.
  • Consider a browser client that enforces pinning by default. If you connect from Chromebooks, iPads, or locked-down laptops, a client that stores pinned keys in an encrypted browser vault gives you the same verification guarantees without managing known_hosts files across devices.

What to do today

  1. Pick one internet-facing server. Check sshd_config: ensure PasswordAuthentication no and PubkeyAuthentication yes.
  2. Verify your local known_hosts has an entry for that server and the fingerprint matches what the server console shows (ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub).
  3. If you use a browser-based SSH tool, confirm it pins host keys and warns on mismatch without a one-click bypass.
  4. If you route SSH through Tor, a VPN, or any proxy, understand that the proxy sees the outer encryption. The inner SSH encryption and host-key verification are what protect the session content and identity.

The network will always be hostile. The protocol gives you the tools to detect and limit the damage. Use them.


SSH Guru is a browser-based SSH client that pins host keys in an encrypted browser vault and keeps private keys local. The AI assistant proposes commands for your approval; it never executes them. Try the free tier at sshguru.com.

Comments

No comments yet. Be the first.

Leave a comment

Comments appear once the author approves them.