CH-J Toolsserver management over SSH
Menu
All guides and articles →

Ed25519 vs. RSA: choosing and installing SSH keys

Choose a compatible key, protect its private half and test the new login before removing the old access method.

What are you changing when you install an SSH key?

You can still log in with a password, but want a protected key for daily administration. Or you already use RSA and need to decide whether to replace it with Ed25519. The practical task is the same: choose an accepted algorithm, generate a pair on your own client, install the public half for the correct server account, and prove that a new connection uses it.

The private key signs an authentication request; the server checks the signature against an authorized public key. Your private key and its passphrase stay on the client. This user key proves your identity. A server host key proves the server's identity and belongs to a separate trust check. Changing your login key does not justify accepting an unexpected host key.

Keep the existing session open and retain a working recovery path, such as the server console. Do not remove the old key or disable password access until a separate connection has passed the checks below.

Should you choose Ed25519, RSA or a hybrid key?

Choose for the actual client, server and security policy, rather than the filename of an existing key. A key supported by your laptop can still be rejected by a restricted server configuration.

  • Ed25519 is a practical choice when both endpoints and organizational policy support it. Its compact public key is convenient to distribute and inspect.
  • RSA with 3072 or 4096 bits is an alternative when compatibility or policy requires RSA. Select the size required by your environment; increasing it does not repair an obsolete SSH implementation.
  • An RSA public key can begin with ssh-rsa while authentication uses rsa-sha2-256 or rsa-sha2-512 signatures. The old ssh-rsa signature uses SHA-1; the public key label alone does not show which signature was negotiated.
  • The hybrid ssh-mldsa44-ed25519 combines ML-DSA-44 with Ed25519. Its design requires breaking both components to forge signatures. Deploy it only after checking support for that exact algorithm on both sides, and retain a compatible fallback.

Post-quantum key exchange and post-quantum authentication are separate parts of SSH. A connection can use hybrid key exchange while authenticating with Ed25519 or RSA. Do not infer support for hybrid user keys from a key-exchange message in the client log.

How do you check compatibility before generating anything?

On the OpenSSH client, these read-only commands show the installed client version, supported key types and supported signature algorithms. They work in a Linux shell and in Windows PowerShell when OpenSSH Client is installed. They describe the local binary, not the remote server's policy.

ssh -V
ssh -Q key
ssh -Q sig

Ask the server administrator which user-key algorithms are accepted. For Linux OpenSSH, PubkeyAuthentication, PubkeyAcceptedAlgorithms and AuthorizedKeysFile are relevant settings; conditional Match rules may change them for an account or address. A distribution may also apply cryptographic policy. Check the installed package documentation when operating under compliance requirements.

For a rejected connection, start with the exact account, hostname and port. A successful test against another account proves little. An unsupported query on an older client is a reason to consult that client's manual, not to enable old algorithms globally.

How do you generate and protect the key locally?

On a Linux client, inspect the destination first. The listing may report missing files, which is expected for an unused name. If either file exists, choose another basename before continuing. Run exactly one generation command, selecting the RSA alternative only if needed.

ls -l ~/.ssh/id_ed25519_chj ~/.ssh/id_ed25519_chj.pub ~/.ssh/id_rsa_chj ~/.ssh/id_rsa_chj.pub
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_chj

Alternatively, generate RSA with the following command. Use a strong, unique passphrase at the interactive prompt. Do not put it in a command argument, shell history or an example script. If prompted to overwrite a file, decline and investigate.

ssh-keygen -t rsa -b 3072 -f ~/.ssh/id_rsa_chj

On a Windows client, use PowerShell and an explicit profile path instead. Inspect the listing and choose an unused name, then run the final command. These Windows commands replace the Linux generation commands above.

New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.ssh" | Out-Null
Get-ChildItem -Force "$env:USERPROFILE\.ssh"
ssh-keygen -t ed25519 -f "$env:USERPROFILE\.ssh\id_ed25519_chj"

The file without .pub is private; the .pub file is public. Keep an encrypted backup of the private file and protect its access permissions. A passphrase helps protect a stolen file but cannot protect a key already usable on a compromised client.

How do you install the public key on Linux?

For a Linux server using the usual per-user AuthorizedKeysFile, install into the target account, not the administrator's account by accident. From a Linux client with ssh-copy-id available, the following command selects only the named public key. Substitute the RSA .pub path if you chose RSA.

  1. Confirm the server host fingerprint through a trusted channel before accepting a first connection.
  2. Authenticate using the existing access method and add the new public key. For a non-standard port, add the appropriate -p option.
  3. If ssh-copy-id is unavailable, display the local .pub file and append its complete single line in the target account's authorized_keys using an editor through an existing trusted session. Preserve existing entries and any key restrictions.
  4. Check ownership and permissions on the server before testing another connection.
ssh-copy-id -i ~/.ssh/id_ed25519_chj.pub user@server.example

Run the following inside the existing server session as the target Linux user. The listing includes the home directory because writable parent directories can also cause rejection. If ownership is wrong, have an administrator correct the specific paths before changing modes. Do not apply recursive permission changes across the home directory.

ls -ld ~ ~/.ssh ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

The public key must remain one physical line, although an editor may wrap it visually. Updating authorized_keys normally needs no sshd restart. A custom AuthorizedKeysFile or centrally managed configuration requires the administrator's installation procedure.

What changes on a Windows OpenSSH server?

On Windows Server 2022 and 2025 with the default OpenSSH configuration, a standard user's authorized_keys belongs in that user's .ssh directory under their profile. Administrator accounts normally use C:\ProgramData\ssh\administrators_authorized_keys instead, because of a default Match rule. Check C:\ProgramData\ssh\sshd_config before deciding which file applies.

Append only the public key as a single plain-text line. Windows uses ACLs, so Linux chmod commands do not apply. The shared administrator file requires access restricted to Administrators and SYSTEM, with inappropriate inherited permissions removed. Follow Microsoft's documented ACL procedure and inspect existing entries first; group names can differ on localized systems.

Anyone who can add a public key to an authorization file can grant access through it. Never fix an ACL problem by giving Everyone write permission.

How do you prove the new key actually works?

Open another terminal on the Linux client. This test disables connection sharing and agent use, names the private file explicitly and permits only public-key authentication. It prevents an existing connection or password fallback from hiding a broken setup. If the account requires additional authentication through server policy, test that full policy separately.

ssh -v -o ControlMaster=no -o ControlPath=none -o IdentityAgent=none -o IdentitiesOnly=yes -o PreferredAuthentications=publickey -i ~/.ssh/id_ed25519_chj user@server.example

On Windows, run the same command in PowerShell but replace the -i path with "$env:USERPROFILE\.ssh\id_ed25519_chj". A private-key passphrase prompt is local and expected. A server account password prompt is different and does not prove key authentication.

Look for a successful publickey authentication message, then check the remote account with whoami. On Linux, compare the offered key fingerprint in verbose output with the local public file using the command below. Record the full fingerprint for later revocation; a filename or comment is not a reliable identity.

ssh-keygen -lf ~/.ssh/id_ed25519_chj.pub -E sha256

Why does a valid key still get rejected?

Read the verbose client output before changing algorithms. Permission denied (publickey) is a final result, not a diagnosis. Establish whether the client offered the intended key and whether the server accepted it.

  • If the key is not offered, check the private-file path, readability, client configuration and selected username. A non-default filename needs -i or an IdentityFile entry.
  • If it is offered but refused, check the target account's authorization file, key line, ownership, permissions and server authentication policy.
  • If too many identities are tried, use IdentitiesOnly=yes with the intended IdentityFile. Replacing a key does not fix an overloaded agent's identity selection.
  • For algorithm mismatch messages, identify whether they concern a user signature, host key or key exchange. Do not globally re-enable SHA-1 ssh-rsa signatures or disable host verification.
  • On SELinux-enabled Linux systems, incorrect file labels can also prevent access. Ask the administrator to inspect labels and server logs rather than disabling enforcement.

How do you manage keys after the first successful login?

Use separate keys for different administrators and devices so that one lost laptop does not require replacing everyone's access. Record which public fingerprints belong to which owners and accounts. Protect backups with the same care as the working private key.

For convenience on a Linux desktop with an existing ssh-agent, load the key for a limited time and inspect the loaded fingerprints. If there is no running agent, use your desktop's documented agent setup. Avoid forwarding an agent to untrusted servers.

ssh-add -t 1h ~/.ssh/id_ed25519_chj
ssh-add -l -E sha256
  1. For planned replacement, add and test the new key first. Then inspect the old authorization entry and remove only that verified entry, preserving other users' access and recovery options.
  2. If a private key is exposed, revoke its public entry everywhere it was authorized and investigate the client. Changing the passphrase on your own copy does not invalidate an attacker's copy.
  3. For unattended jobs, use a dedicated account and the narrowest suitable authorization restrictions. Do not distribute a personal administrator key to automation hosts.

How does CH-J Tools help with key choice?

CH-J Key Generator is already available in Beta 0.1.0. In Beta 0.1.2, CH-J Key Generator creates ssh-mldsa44-ed25519 keys. CH-J Tools adds this key type to a server only when the server runs OpenSSH 10.6 or newer.

Older releases reject this key type; some recognize only an experimental variant ending in @openssh.com, which CH-J Tools does not use. Keep an Ed25519 or RSA key as a fallback for clients and servers without support. The existing upgrade guide in the sources describes installing OpenSSH 10.6 alongside the distribution package.

Frequently asked questions

Can I convert an RSA key into Ed25519?

No. Generate a new pair and authorize its public key. A format conversion changes storage or encoding, not the underlying algorithm.

Does the public-key comment have to match my username?

No. The trailing comment is a label for people. Authentication depends on the key material and the account where it is authorized.

Can I recover a lost private-key passphrase?

There is no passphrase reset that decrypts the original file. Use another authorized access method to install a replacement key if you cannot unlock the old one.

Can I recreate a missing .pub file?

Yes, if you still have the usable private key. ssh-keygen -y -f followed by the private-file path prints its public key; save that output to a new public filename.

Does a passphrase protect an already open SSH session?

No. It protects the stored private key. Once a client or agent can sign, workstation access controls and session locking remain essential.

Detailed documentation

OpenSSH: ssh-keygen →

OpenSSH: sshd_config →

OpenSSH 10.6 for post-quantum SSH keys →

OpenSSH 10.6 pro postkvantové SSH klíče →

OpenSSH: ssh →

OpenSSH: ssh_config →

OpenSSH: sshd →

OpenSSH: ssh-add →

Microsoft: key-based authentication in OpenSSH for Windows →

OpenSSH: release notes →

Biometric unlock and security →

All tutorials by category →