↑ ↓ select, Enter open, Esc close

Copy your public SSH key to a server

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
user@server
ssh-copy-id -i ~/.ssh/id_ed25519_server.pub -p 22 webuser@server.example.com

Logs in to the server once with a password and appends the public key to the target user’s ~/.ssh/authorized_keys. Missing directories are created with the correct permissions. Keys that are already present are detected and not added twice.

Note: Afterwards, test the key login in a second session before disabling password authentication.

Also searched as

  • how to copy ssh key to server
  • ssh-copy-id custom port
  • set up passwordless ssh login

Related one-liners

All in SSH

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.