Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

ssh-copy-id equivalent for giving a client a key for a server?

Writer Matthew Harrington

I’m currently delving more into homeserver activities, and I was wondering if there was a way to add a client to my server’s list of allowed keys for SSH. I currently have SSH set up to use PublickeyAuthentication in my sshd_config, and I feel like having to turn this setting off every time I want to add a new client to SSH from is insecure. Is there a serverside command I should be using for this? Thank you!

1 Answer

The equivalent on a server would be to just add the public key to the ~/.ssh/authorized_keys file in whichever way you like. There's no dedicated command for doing so.

For example, you could carry your new client computer's id_rsa.pub to the server on a USB stick, or relay it via 'scp' or 'sftp' through an already-trusted computer, or manually type it in, or use a hardware-protected portable key such as a Yubikey for the initial connection. (There are probably 10 more different methods to do it.)

ssh-copy-id basically just does:

  1. uploads id_rsa.pub using scp;
  2. appends it using cat your_uploaded_key.pub >> ~/.ssh/authorized_keys on the server.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy