I’ve had to create a user on my linux server a number of times in the last few months and every time I have to look up how to do it.
To create a user for your linux server…
$ useradd <username>
… without alias, on mine anyway…
You will probably need to use sudo or to switch to root user $ su, unless you’re ssh’ing in under root. Word to the wise: “Don’t!” Really for security you should disable root access via ssh and allow switch user or su.
$ passwd <username>
Specify a home directory for user:
$ usermod -d <path/to/directory> <username>
Or you can add the home directory when creating the user:
$ useradd <username> -d <path/to/directory>
Nice note: this will create the directory if it isn’t already created.
Allow ssh access under this user; edit your sshd_config file. For me this file is here: /etc/ssh/sshd_config
Search for ‘AllowUsers’ in this file.
Note: In Nano ctrl + w is to search and in VIM ‘/’ and your string while not in ‘insert’ mode will allow you to search.
Add your new user to this line. Users are separated by only a space, no comas dashes or anything; example:
AllowUsers sparkmasterflex bob fred
… will allow three users ssh access (sparkmasterflex, bob and fred)
Then you need to reload the sshd:
$ /etc/init.d/sshd/ restart