Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

17 November 2026 · One command a day

How do I copy my SSH key to a server so I can log in without a password?

The ssh-copy-id command copies your public SSH key onto a server and adds it to the list of keys that are allowed to log in. After that, SSH uses your key and stops asking for a password. Use it once for each new server, straight after you have made a key pair.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

The command

ssh-copy-id -i ~/.ssh/id_ed25519.pub user@host

Run this on your own computer, not on the server. -i ~/.ssh/id_ed25519.pub chooses which public key to send. If you leave it out, the command picks the most recent id_*.pub file in ~/.ssh. user@host is the account and the server you log in to, such as user@example.com. It logs in once with your password, adds the key to ~/.ssh/authorized_keys in that user's home folder, and creates the folder with the right permissions if it is not there yet. It does not need sudo. If you do not have a key yet, see how to create an SSH key pair with ssh-keygen.

What you will see

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/user/.ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
user@example.com's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'user@example.com'"
and check to make sure that only the key(s) you wanted were added.

The first line shows which key file it is sending. Then it checks whether the key is already on the server, and it only asks for your password if the key is missing. Number of key(s) added: 1 means it worked. If it says the keys already exist and nothing was added, the server already trusts that key. Now run ssh user@example.com. You should get a shell without being asked for a password. You may be asked for the key's passphrase if you set one.

When to use it

Watch out for

Do not turn off password logins until you have tested the key. Open a second terminal, run ssh user@host, and make sure it lets you in without a password. Only then set PasswordAuthentication no in /etc/ssh/sshd_config and run sudo systemctl reload ssh. Keep your current session open while you do this. If something is wrong you can still fix it, and you will not lock yourself out.

Questions people ask

Does ssh-copy-id replace keys that are already on the server?

No. It adds your key to the end of ~/.ssh/authorized_keys and skips keys that are already there, so other keys keep working.

What if SSH on the server uses a different port?

Add -p and the port number, for example ssh-copy-id -p 2222 -i ~/.ssh/id_ed25519.pub user@host.

Choosing how you log in, and turning off passwords once keys work, is the kind of thing you can only do on a server you control. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related server notes: How do I create an SSH key pair on Linux with ssh-keygen? · How do I copy a folder to another server with rsync? · How do I copy a file to or from a server with scp? · All daily notes