ssh-copy-id equivalent for giving a client a key for a server?
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:
- uploads id_rsa.pub using
scp; - appends it using
cat your_uploaded_key.pub >> ~/.ssh/authorized_keyson the server.