basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    Check the server’s fingerprint before you answer yes

    On the first login ssh shows the server key’s fingerprint and asks yes/no. Compare it with what the server itself reports through the provider console — then known_hosts remembers the real server, not whoever sits in the middle.

    What the first login shows

    The authenticity of host '203.0.113.10 (203.0.113.10)' can't be established.
    ED25519 key fingerprint is SHA256:9x8n…Qe0.
    This key is not known by any other names.
    Are you sure you want to continue connecting (yes/no/[fingerprint])?

    yes writes the key into ~/.ssh/known_hosts, and from then on ssh checks it on every login. If someone in the middle answered the first time, their key gets remembered — and the check protects them, not you.

    How to compare

    In the provider console (it bypasses the network where a man in the middle could sit), run on the server:

    ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
    # 256 SHA256:9x8n…Qe0 root@web1 (ED25519)

    If it matches the prompt, answer yes. You don’t have to compare by eye: paste the fingerprint from the console instead of yes, and ssh compares it itself.

    GitHub publishes its fingerprints in the documentation: SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU for ED25519 — the same one you see on the first ssh -T [email protected].

    After a reinstall the host keys are new, and ssh warns REMOTE HOST IDENTIFICATION HAS CHANGED. That’s expected — but only if the server was in fact reinstalled. Compare the same way, and only then run ssh-keygen -R 203.0.113.10.

    If it doesn’t work

    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! after reinstalling the server

    Cause
    A new system means new keys in /etc/ssh/ssh_host_*, while known_hosts has the old one.
    Fix
    Compare the new fingerprint through the provider console, remove the old entry with ssh-keygen -R 203.0.113.10, and log in again.

    The same warning, and nobody touched the server

    Cause
    Either the address went to another server, or the connection is being intercepted.
    Fix
    Don’t log in and don’t type passwords. Check the fingerprint through the provider console; if it doesn’t match what ssh shows, look into the network, not known_hosts.