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.
$ useradd tunneluser -m -d -/home/tunneluser -s /bin/true
# or
$ useradd tunneluser --create-home --home-dir /home/tunneluser --shell /bin/true
-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 shellthe value
/bin/true
simply returns true by doing nothing, successfullythis is useful to prevent remote users who connects via SSH, from accessing the shell and perform actions such as file transfers (SCP) 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:
$ passwd tunneluser
Last updated