To create a new user account in Ubuntu, replace new_user with the username you want to add in the follow commands.
An interactive root session avoids a lot of sudo prefixes.
will create the user account, prompting you for user details and a password.
usermod -a -G www-data new_user
will add them to the www-data group, such as for web admins. Replace www-data with the groups they should be a part of.
chage -m 0 -M 99999 -I -1 -E -1 new_user
will remove the password expiry so that the user doesn’t need to change a password regularly
usermod -a -G sudo new_user
will give the user sudo permissions if they require this level of access
mkdir /home/new_user/.ssh cd /home/new_user/.ssh ssh-keygen -t rsa -b 4096 (enter './id_rsa' when prompted) chown new_user:new_user /home/new_user/.ssh/ \ /home/new_user/.ssh/authorized_keys \ /home/new_user/.ssh/id_rsa \ /home/new_user/.ssh/id_rsa.pub chmod 600 /home/new_user/.ssh/authorized_keys /home/new_user/.ssh/id_rsa chmod 644 /home/new_user/.ssh/id_rsa.pub chmod 700 /home/new_user/.ssh
will create the SSH key directory and generate a new key for use when logging in to the Ubuntu system via SSH. The final permission settings are necessary as an SSH session won’t be allowed when the keys are not restricted on the file system.
will display the content of the private key file, which will need to be provided to the user to allow them to access the Ubuntu system.
your elevated session.