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. set 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. give the `me` user `sudo` (admin) privileges
16 5. allow `me` to `sudo` without a password
19 How to create a new user named 'me':
22 # --disable-password prevents a password prompt
23 # --gecos "" skips the useless questions
24 adduser --disabled-password --gecos "" me
27 How to create a and set a random password:
30 # sets 'my_password' to 32 random hex characters (16 bytes)
31 my_password=$(openssl rand -hex 16)
33 # uses 'my_password' for to reset and confirm 'me's password
34 printf "$my_password"'\n'"$my_password" | passwd me
37 How to make the user 'me' a "sudo"er (an admin):
43 How to allow 'me' to run sudo commands without a password:
46 echo "me ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/me
49 How to copy allowed keys from root to the new user:
52 mkdir -p /home/me/.ssh/
53 chmod 0700 /home/me/.ssh/
55 cat "$HOME/.ssh/authorized_keys" >> /home/me/.ssh/authorized_keys
56 chmod 0600 /home/me/.ssh/authorized_keys
58 chown -R me:me /home/me/.ssh/