0

How to copy the public ssh keys from other users to to their ~/.ssh/authorized_keys on a remote server?

I'm aware of the 'ssh-copy-id' command, but I assume it only work if the user has currently normal access via their password on the remote computer. I could copy the files with SCP to my own directory, then login and copy the the files to the users directory, but I would like to have a method that does not involve extra handling on the remote server.

  • Only ssh password-less-login is allowed (None of the users are allowed to login with password
  • Currently one user (me) has password-less-login access and has 'sudo' rights
  • Assume other users don't have a '~/.ssh' directory

local client: MacOs X

remote server: Debian

  • Upload, move, change owner, set permissions. Are you looking for someone to write a script for you? – Tyson Dec 6 '14 at 15:22
0

Your best bet is to write a script.

There is a sshd configuration parameter called AuthorizedKeysFile by default is is set to .ssh/authorized_keys .ssh/authorized_keys2

You could create user specific keys is /etc/sshd/authorized_keys.%u

Example: /etc/ssh/sshd_config

AuthorizedKeysFile /etc/ssh/authorized_keys.%u .ssh/authorized_keys .ssh/authorized_keys2

Then you create /etc/ssh/authorize_keys.pyther. You would put my public key in the file. When I log in, I would use my private key.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.