byFrancis Kim
inRandom
posted November 29, 2016
Right now I’m having to create multiple users on multiple Ubuntu instances, I hope the following steps will be of use to someone. Although it’s for Ubuntu it should be the same process for all linux and most *nix OS’s.
# (running as root) useradd -m foobar adduser foobar sudo cd /home/user/foobar mkdir .ssh chown foobar:foobar .ssh && chmod 700 .ssh cd .ssh vim authorized_keys # (paste in the public SSH key) chown foobar:foobar authorized_keys && chmod 600 authorized_keys passwd foobar # (set a temporary password, get the user to change it) service ssh restartThe above commands will correctly set the permission and file/directory owner.