3 homepage: https://webinstall.dev/ssh-adduser
5 SSH adduser: Because friends don't let friends login or run stuff as root
8 Many modern web programs (`npm` and `postgres`, for example) will not function correctly if run as root.
13 2. sets a random, 32-character password (as a failsafe)
14 3. copy the `root` user's **`~/.ssh/authorized_keys`** (so the same users can still login)
15 4. gives the `me` user `sudo` (admin) privileges
16 5. allows `me` to `sudo` without a password
19 How to create a new user named 'me':
22 # Note: --disable-password means that the user cannot yet login
23 adduser --disabled-password --gecos "" me
26 How to create a and set a random password:
29 # store a random 16-byte password into 'my_password'
30 my_password=$(openssl rand -hex 16)
32 # use 'my_password' to set the user 'me's password
33 printf "$my_password"'\n'"$my_password" | passwd me
36 How to make the user 'me' a "sudo"er (an admin):
42 How to allow 'me' to run sudo commands without a password:
45 echo "me ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/me
48 How to copy allowed keys from root to the new user:
51 mkdir -p /home/me/.ssh/
52 chmod 0700 /home/me/.ssh/
54 cat "$HOME/.ssh/authorized_keys" >> /home/me/.ssh/authorized_keys
55 chmod 0600 /home/me/.ssh/authorized_keys
57 chown -R me:me /home/me/.ssh/