Skip to main content
+44 7575 472931[email protected]
HostaccentKnowledge BaseHosting, websites, SEO, and growth

How to Generate SSH Key: Ed25519 Setup + 5 Fixes (2026)

How to generate SSH key pairs with the ssh-keygen Ed25519 command, copy them with ssh-copy-id, log in without a password and fix keys the server refuses.

VPSSecurityBeginner Guide
How to generate SSH key pairs for passwordless login: Ed25519 terminal workflow with ssh-copy-id and permission fixes

You've typed the same server password ten times today, or your provider just announced password logins are being switched off. Either way, learning how to generate SSH key pairs takes about 2 minutes, and it's the biggest single security upgrade you can make to a Linux server.

Quick Answer: On your own computer, run ssh-keygen -t ed25519 -C "work-laptop", press Enter to accept the default path, and set a passphrase. Install the public key with ssh-copy-id user@server_ip, then test with ssh user@server_ip. If the server still asks for a password, run chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys on the server and try again.

Last verified: October 2026, against OpenSSH 10.6 (upstream), Ubuntu 26.04 LTS (ships OpenSSH 10.2), Ubuntu 24.04 LTS (OpenSSH 9.6) and the OpenSSH client built into Windows 10 and 11.

Our team resolves 20 to 30 client issues every day, and "my key isn't working" shows up on that list constantly. This guide follows the order we use to fix it, so you can do it yourself.

How to Generate SSH Key Pairs With ssh-keygen

Generate the key on the computer you connect from, never on the server, so the private half never leaves that machine.

On Linux, macOS or Windows 10/11 (PowerShell), this is the ssh-keygen Ed25519 command we recommend for every new key:

bash
ssh-keygen -t ed25519 -C "work-laptop"

Press Enter to accept the default path (~/.ssh/id_ed25519), then type a passphrase twice. You now have two files:

  • id_ed25519 is your private key. Never email, paste or upload it.
  • id_ed25519.pub is your public key, safe to copy onto any server.

Most guides put your email in the -C comment. Use the device name instead: when a laptop goes missing two years from now, that label is how you'll find and delete the right line on every server.

As of October 2026, Ed25519 is the right key type for almost every server. It has been the ssh-keygen default since OpenSSH 9.5, produces a 256-bit key whose public half fits on one short line, and is standardised for SSH in RFC 8709. Use ssh-keygen -t rsa -b 4096 only for legacy systems older than OpenSSH 6.5, released in 2014.

Still using an old id_dsa key? Replace it, because OpenSSH 10.0 removed DSA entirely in April 2025. Every flag is documented in the official ssh-keygen manual page, and Windows users can confirm the built-in client is installed using Microsoft's OpenSSH for Windows guide.

Should I set a passphrase if the whole point is no password?

Yes. The passphrase never travels to the server; it only unlocks the key on your machine, so a stolen laptop doesn't hand over your servers too. Load it into the agent once per session and you won't be asked again:

bash
ssh-add ~/.ssh/id_ed25519

On a Mac, add --apple-use-keychain to remember it across reboots. Leave the passphrase empty only for an automation key that does one job, such as a nightly backup.

Pro Tip: Make one key per device rather than copying a single private key between laptops. Revoking one lost machine then means deleting one line, not re-keying every server you own.

Copy the Public Key to Your Server With ssh-copy-id

ssh-copy-id logs in with your password one last time, appends your .pub file to ~/.ssh/authorized_keys and sets safe permissions. On Linux and macOS:

bash
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]

For a non-standard port, add -p 2222 (and read how to change the SSH port without locking yourself out before moving it).

Windows doesn't ship ssh-copy-id, so pipe the key across instead:

powershell
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh [email protected] "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

If passwords are already disabled, paste the key through your provider's web console, or use cPanel's SSH Access > Manage SSH Keys > Import and then click Authorize. An imported key that was never authorised is a miss we see often; our guide to what a proper cPanel server setup covers shows where that screen lives.

The key must also land in the right account: a key in /root/.ssh does nothing for a user called deploy. If that account doesn't exist yet, add the Linux user with the right groups and permissions before copying anything.

A correct authorized_keys entry is exactly one line: the type (ssh-ed25519), a base64 blob of 68 characters for Ed25519, then your comment. As of October 2026 every OpenSSH server from version 6.5 onward reads that format, so a pasted key that wraps onto two lines or starts with ---- BEGIN (PuTTYgen's "Save public key" output) will be rejected.

Now test it in a fresh terminal:

bash
ssh -i ~/.ssh/id_ed25519 [email protected]

The first connection asks you to confirm the server's fingerprint. If you get a warning that the host key has changed, stop and follow our safe fix for host key verification failed before typing yes.

Professional help available

Still working through this server issue?

Send the symptoms, error output, and what you have already tried. We can work with Hostaccent services or infrastructure hosted with another provider.

Request server helpHow server support worksHosted elsewhere? One-time paid support is available after scope and price confirmation.

SSH Key Not Working After Copy? Fix It in This Order

A password prompt means the server is ignoring your key, nearly always because of permissions, ownership or a different key being offered. Start with ssh -v [email protected] and read two lines: "Offering public key" and "Authentications that can continue".

According to Hostaccent's support queue, where our engineers resolve 20 to 30 client issues every day, key logins that still ask for a password come down to three causes far more than any others: loose permissions, the wrong account, or the wrong key being offered.

The 60-Second Key Audit

Our team runs these three checks on the server before touching anything else:

bash
stat -c "%a %U %n" ~ ~/.ssh ~/.ssh/authorized_keys
  1. Mode. Home not writable by group or others, ~/.ssh at 700, authorized_keys at 600.
  2. Owner. All three belong to the login user. Editing with sudo nano quietly makes root the owner.
  3. Path. The file sits in that user's home, named exactly authorized_keys (no .txt).

This block will fix authorized_keys permissions, ownership and the home folder in one go:

bash
chmod go-w ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chown -R $USER:$USER ~/.ssh

OpenSSH silently ignores authorized_keys when the file, the ~/.ssh folder or the home directory can be changed by another user. As of October 2026, the safe values are 700 for ~/.ssh and 600 for authorized_keys, both owned by the login user, and the server log line "bad ownership or modes" confirms this cause in under 30 seconds.

If the audit passes, work through the remaining causes:

  • Wrong key offered. Use -i, or set IdentityFile for that host in ~/.ssh/config. On OpenSSH 10.5 or newer, ssh -Z [email protected] prints the exact order your keys will be tried.
  • "Too many authentication failures". Your agent offers other keys first; add IdentitiesOnly yes for that host.
  • SELinux labels on AlmaLinux or Rocky: run restorecon -Rv ~/.ssh.
  • "Unprotected private key file" warning. Run chmod 600 ~/.ssh/id_ed25519 locally.

Pro Tip: The server tells you why a key was refused; the client never does. Run sudo journalctl -u ssh -n 50 on Ubuntu or Debian (use -u sshd on AlmaLinux and Rocky) and look for "Authentication refused".

Turn Off Password Logins Without Locking Yourself Out

Once a key login works from a fresh window, switch password authentication off, but check the drop-in folder first: on modern Ubuntu the main config file often isn't the one that wins.

Prove the key works with passwords forcibly disabled on the client side:

bash
ssh -o PasswordAuthentication=no [email protected]

If that works, keep the session open. Ubuntu's /etc/ssh/sshd_config starts with an Include line for sshd_config.d/*.conf, and sshd keeps the first value it reads. Cloud images often ship a 50-cloud-init.conf that says PasswordAuthentication yes, which silently beats your edit in the main file. So create a file that sorts first:

bash
printf 'PasswordAuthentication no\nKbdInteractiveAuthentication no\n' | sudo tee /etc/ssh/sshd_config.d/00-keys-only.conf
sudo sshd -t && sudo systemctl reload ssh
sudo sshd -T | grep -iE 'passwordauthentication|kbdinteractive'

On AlmaLinux or Rocky, reload sshd instead. Skip the old advice to set UsePAM no; it can break account checks. Every directive is explained in the sshd_config manual.

Disabling password authentication turns every automated guessing attempt into an instant refusal. As of October 2026, the reliable check is sudo sshd -T, which prints the settings sshd is really using. If it still shows passwordauthentication yes after your edit, a file in sshd_config.d is overriding you, and the whole fix takes about 5 minutes.

Insider Insight: Across the 4,000+ site migrations Hostaccent has handled since 2016, one of the lockouts we're most often asked to undo has nothing to do with a lost key. Someone switched passwords off before testing the key from a second window. Keep your current session open until a brand-new login succeeds.

Ubuntu's default PermitRootLogin prohibit-password already lets root in with a key but never a password. Keep a strong root password anyway for console recovery; our guide on how to change the root password in Linux safely covers that in three steps.

Your Next Step: A Server Where Key-Only Login Is Yours From Day One

Now that you know how to generate SSH key pairs, copy them across and switch passwords off without a lockout, the last piece is a server you fully control. You could keep working around a box where someone else sets the rules, or start on a VPS where your key goes in before the first login. Hostaccent's Standard plan at $12.00/mo (it renews at $12.00/mo too) gives you full root access, free 30 Gbps DDoS protection, 24/7 help from our own engineers and a 30-day money-back guarantee. One honest caveat: no control panel licence is bundled, so budget separately if you want cPanel or Plesk. If that fits, start on the Standard plan for $12.00/mo.

Frequently Asked Questions

How to generate SSH key on Windows 11 without PuTTY?

Windows 10 and 11 include the OpenSSH client, so open PowerShell or Windows Terminal and run ssh-keygen -t ed25519. Press Enter to save the key under C:\Users\yourname\.ssh\ and set a passphrase. You only need PuTTYgen if an older tool demands a .ppk file. Because Windows lacks ssh-copy-id, pipe the .pub file to the server with type and ssh, then test the login from a new window.

Is Ed25519 better than RSA for SSH keys?

For server logins in 2026, yes. Ed25519 keys are shorter, faster to verify and avoid the weak-parameter mistakes that older RSA setups made, which is why OpenSSH has generated them by default since version 9.5. RSA at 4096 bits is still safe and remains the fallback for legacy systems or appliances that predate OpenSSH 6.5. DSA is gone completely, so replace any old DSA key now.

Can I use the same SSH key on multiple servers?

Yes. A public key can sit in the authorized_keys file of as many servers and accounts as you need, and ssh-copy-id makes adding it to each one a ten-second job. Just don't share one private key across several computers or people. Give every device and person their own pair, so you can revoke a single laptop or a departing contractor by deleting one line instead of rebuilding access everywhere.

What happens if I lose my private SSH key?

It can't be recovered. Generate a new pair, then log in through your provider's console or a password session and add the new public key. Delete the old key's line from authorized_keys so a found laptop can't be used, then test the new key from a second window. If you still have the private key but lost the .pub file, rebuild it with ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/.ssh/id_ed25519.pub in a couple of seconds.

Why does SSH still ask for a password after ssh-copy-id?

Usually the server is refusing the key because of loose permissions or the wrong owner on your home folder, the .ssh directory or the authorized_keys file. Less often, the client offers a different key or you installed it for another account. Run ssh -v to see which key is offered, then check the server log for "bad ownership or modes". Setting 700 on .ssh and 600 on authorized_keys fixes most cases within a minute.

Professional help available

Still not resolved? Let a server specialist take it from here.

Send the symptoms, error output, and what you have already tried. We can work with Hostaccent services or infrastructure hosted with another provider.

  • No hosting transfer required
  • Scope confirmed before paid work
  • No changes before your approval
Request server helpHow server support worksHosted elsewhere? One-time paid support is available after scope and price confirmation.
Reviewed by

Hostaccent Editorial Team

Reviewed for technical accuracy and clarity before publication.

Last updated

Nov 9, 2026

HostAccent Editorial Team publishes practical hosting guides, operations checklists, and SEO-focused tutorials for businesses building international web presence.

Discussion

Have a question or tip about this topic? Share it below — your comment will appear after review.

Your email stays private and is only used for moderation.

Write for the Community

Have a tutorial, tip, or insight to share? Get published on the Hostaccent Blog with your name, bio, and website link.

Become a Contributor

Need a faster setup for this workflow?