useradd

useradd - create a new user or update default new user information

Example

Suppose we want to create a user named tunneluser that is used primarily to accept SSH connections (eg. for tunneling, etc.). This user should have no access to the shell console.

  • -m/--create-home : create the user's home directory if it does not exit

  • -d/--home-dir HOME_DIR : the new user will be created using HOME_DIR as the user's login directory

  • -s/--shell : sets the path to the user's login shell

    • the value /bin/true simply returns true by doing nothing, successfully

    • this is useful to prevent remote users who connects via SSH, from accessing the shell and perform actions such as file transfers (SCParrow-up-right) or command execution.

Next, we have to make sure to set a strong password to prevent anyone from simply connecting to our machine via SSH:

Last updated