Adding users to a server...?

How do I “add users” to an Ubuntu 10 Server so that they can log into it using something like WinSCP or PuTTy to add / edit / remove files from their respective web space?

From an ssh shell,the useradd command is your friend

sudo useradd


Usage: useradd [options] LOGIN

Options:
  -b, --base-dir BASE_DIR       base directory for the home directory of the
                                new account
  -c, --comment COMMENT         GECOS field of the new account
  -d, --home-dir HOME_DIR       home directory of the new account
  -D, --defaults                print or change default useradd configuration
  -e, --expiredate EXPIRE_DATE  expiration date of the new account
  -f, --inactive INACTIVE       password inactivity period of the new account
  -g, --gid GROUP               name or ID of the primary group of the new
                                account
  -G, --groups GROUPS           list of supplementary groups of the new
                                account
  -h, --help                    display this help message and exit
  -k, --skel SKEL_DIR           use this alternative skeleton directory
  -K, --key KEY=VALUE           override /etc/login.defs defaults
  -l, --no-log-init             do not add the user to the lastlog and
                                faillog databases
  -m, --create-home             create the user's home directory
  -M, --no-create-home          do not create the user's home directory
  -N, --no-user-group           do not create a group with the same name as
                                the user
  -o, --non-unique              allow to create users with duplicate
                                (non-unique) UID
  -p, --password PASSWORD       encrypted password of the new account
  -r, --system                  create a system account
  -s, --shell SHELL             login shell of the new account
  -u, --uid UID                 user ID of the new account
  -U, --user-group              create a group with the same name as the user
  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mappi             

Thanks for that info, Tim.

I finally had some time to tinker with this and here’s where I am (feel free to offer some sage advice):

After using “sudo useradd -gusers -s/bin/shell -proger -d/home/roger -m roger”, I then load up PuTTY to see if I can log into the server using this user’s credentials (to test everything) and it says that “Access denied” after typing the password.

Any idea what’s going on? Obviously, I’ve apparently done something wrong but I’m at a loss as to what exactly.

Try resetting the user’s password using sudo passwd

Tried it. Still getting “Access denied.”

When I do “ls -l /home”, I receive the following information:

drwxr-xr-x 26 admin admin 4096 2011-02-03 13:05 admin
drwxr-xr-x 2 roger 1001 4096 2011-01-31 13:26 roger

The reason I mention this is because I would hate to think that this has something to do with permissions…?

Edit the file, /etc/passwd - look at the line that relates to your user, and the line that relates to the new user… Make sure the shell is the same and then try again.

sudo passwd roger

will allow you to set / update the password for the user.

Root is the following:

root: x:0:0:root:/root:/bin/bash

roger is the following:

roger: x:1001:100::/home/roger:/bin/shell

I’m trying to allow each user to have control over only their respective directory. In essence, what I’m trying to do here is add people to the server so that they can have web space. At the moment, however, I’m just trying to establish ANYTHING by using this home/[username] approach.

Is /bin/shell a valid shell on your server? (My guess would be no)

try editing the file and changing that to /bin/bash like the root user.

You rock, Tim; that was it. But what would you advise in regards to setting up individual accounts in the “www” directory? I would love to allow each user to have full control over their respective directories in www, but anything outside of that would be a no-no.

Would this revolve entirely around permission usage or is there anything special I would need to do in creating these accounts?

Yep, its down to permissions if you want to use the /var/www/ folder

the other way, is to set up users domains in their “public_html” folder (/home/user/public_html/) that way they can manage their own sites and no-one elses.

Tim, that last part you mentioned about managing their own sites is EXACTLY what I’m trying to do here. How do I setup domains?

I found this link. Is that all there is to it???

in a quick and dirty form, yes, that’ll allow you to use the ~username form of access to a users site.

If you want to use their own domains, then you’ll need to add simple blocks to the apache config for each domain (Virtual Hosting) - theres plenty of guides on how to do that out there. (try howtoforge.com as a good place to start)