I am trying to add a new user to an existing droplet that already has a root user that requires a key for login. Originally I wanted the new user to be able to log in with a key too for security, but I guess I am a dumb ass because I have no idea what the tutorials regarding SSH Keys are trying to get me to do (except the ones that only show you how to add one to root, but those are currently useless to me). At this point, I’d be willing to call it a success if I could even get a new user that works without requiring a key but despite not doing anything to the user except creating it, I cannot seem to get it to log in as it wants a key for that user.
At this point I am grasping at strawing and pulling out my hair. I have no idea what to do and no idea what to do past this.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!
@julianswebb
Adding a new user can be done with
useradd
, though getting everything to work with an SSH Key requires a little more work.1). Create Users’ Home and .ssh Directories
2). Touch
authorized_keys
(creates the file)3). Add Public Key to
authorized_keys
. You’ll replace....
with the public key.4). Add new user and set home directory.
5). Setup proper permissions.
6). Reduce permissions on /home/newuser.
…
Keep in mind, this isn’t a
sudo
user - it’s a basic user with no real privileges other than the ability to login using SSH (not SFTP), thus can’t escalate toroot
. If you need to make this user asudo
user, you can use:The above appends the
sudo
group to the user, which will allow them to run commands using:For example:
adduser foo
, public keys go into ~/.ssh/authorized_keys