Add User to Linux
To add a user to a Linux system use the add user command:
bash
sudo adduser usernameTo enable sudo privileges for the user, add the user to the sudo group:
bash
sudo usermod -aG sudo usernameTo setup a ssh key for the user, switch to the user and create the .ssh directory:
bash
sudo su - username
mkdir ~/.ssh
chmod 700 ~/.sshThen create the authorized_keys file and add the public key:
bash
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
vim ~/.ssh/authorized_keysPaste the public key into the file and save it. The user should now be able to log in using the ssh key.
To enable sudo without a password, edit the sudoers file:
bash
sudo visudoAdd the following line to the end of the file:
bash
username ALL=(ALL) NOPASSWD:ALL