The Command
ssh-copy-id user@your_server_ipRun it on your own computer. It logs in with the account password, appends your public key to ~/.ssh/authorized_ on the server, creates ~/.ssh if it is missing, and skips keys that are already there. You need a key pair first; see how to generate SSH keys.
Choose the Key and the Port
Without options, ssh-copy-id picks your default keys. Name one with -i, and add -p when SSH listens on another port:
ssh-copy-id -i ~/.ssh/id_ed25519.pub -p 2222 user@your_server_ipPoint -i at the .pub file. Only the public key is sent; the private key stays on your computer. To see which keys would be installed without changing anything, add -n for a dry run.
Test the Key Login
Open a new terminal and connect:
ssh -i ~/.ssh/id_ed25519 user@your_server_ipIf you set a passphrase, ssh asks for that instead of the account password. That is the sign the key works. If it still asks for the account password, or fails, see Permission denied (publickey).
Add the Key by Hand
Where ssh-copy-id is not available, pipe the key through ssh. This creates the folder and the file with the right permissions:
cat ~/.ssh/id_ed25519.pub | ssh user@your_server_ip "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"Use >>, which appends. A single > would replace every key already in the file.
Add the Key from the Server Console
If password login is already off and you have no working key, open the console in your provider's control panel, log in as the user, and paste the public key line into the file:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keysIf you created the file as root for another user, give it back to that user, or sshd will ignore it:
sudo chown -R user:user /home/user/.sshThe Permissions sshd Expects
| Path | Mode | Owner |
|---|---|---|
~ (home) | not writable by others | the user |
~/ | 700 | the user |
authorized_ | 600 | the user |
Several Keys on One Account
Each line of authorized_ is one key. Add a key for each computer you work from instead of copying one private key around. The comment at the end of each line tells you whose key it is; to revoke access, delete that line.
Keys Added in the Control Panel
Many providers let you store a public key in the control panel and place it on the server when it is created or reinstalled. Check which account receives it, often root or the image's default user. A key added in the panel later may not reach a server that is already running; in that case add it with ssh-copy-id.
Common Messages
- No identities found: ssh-copy-id found no public key. Create one with ssh-keygen, or point
-iat the right.pubfile. - All keys were skipped: the key is already in
authorized_. Nothing needs to be done; test the login.keys - Permission denied: the password was wrong, or the server no longer accepts password logins. Use the console method above, or a key that already works.
- Connection refused or timed out: check the port with
-pand the address before anything else.
After the Key Works
With key login confirmed for a user with sudo, you can turn off password logins: see how to disable SSH password authentication.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations