I have N hosts where can I do passwordless login via ssh to user root
.
For those machines I like to add a ssh-pub-key to authorized_keys of user postgres
.
Goal: I want passwordless login to user postgres
, too.
AFAIK the tool ssh-copy-id
does not help here, since I want the action "add ssh-pub-key to user postgres" to be passwordless.
How to solve this?
Best Answer
Well, if you can login passwordlessly as root you could do something like this I guess:
which will first copy the public key (again) to the remote host, then add that file to the authorized_keys of the postgres user and make sure it has the right permissions. It'll also make sure the postgres/.ssh directory exists and has the right ownership/permissions