Add key to authorized_users without needing to restart sshd

Is the restart of sshd needed?

Not usually. Linux distributions usually ship with a default configuration that allows public key authentication, so you usually don't even have to edit configuration to enable it, and so restarting is unnecessary. Even in the case that you had to do something with sshd_config, you'd only have to restart it only once after editing that file, not for each edit after of the authorized keys file.

Note that you don't even have to restart sshd. From man sshd:

sshd rereads its configuration file when it receives a hangup signal, SIGHUP, by executing itself with the name and options it was started with, e.g. /usr/sbin/sshd.

And the typical systemd service for sshd recognizes this, so you can do systemctl reload sshd instead.

If sshd is restarted, is there a service outage at that time?

Depends on your definition of service outage. A simple restart of sshd will not kill existing ssh connections, but new connections wouldn't be accepted until sshd finishes restarting.


The best way is to use

ssh-copyid [email protected]

Where N is the IP address

OR

ssh-copyid user@fqdn

where fqdn is the Fully Qualified Domain Name (eg server.domain.com)

This does not require any daemon restarts