4

I have raspberry pi 2 with the latest raspian and I am trying to set up an FTP server using this guide.

I am stuck at the part of

useradd ftpuser -g ftpgroup -s /sbin/nologin –d
/dev/null

when I hit enter (as sudo or as pi) it prints me the usage:

Usage: useradd [options] LOGIN
       useradd -D
       useradd -D [options]

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
  -R, --root CHROOT_DIR         directory to chroot into
  -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 mapping

I gave the whereis nologin and it printed

nologin: /usr/sbin/nologin /usr/share/man/man5/nologin.5.gz /usr/share/man/man8/nologin.8.gz

When I tried with /usr/sbin/nologin it gives me the same output.

What do I miss? How to check if the user created?

  • You can check if the user was created by doing the following cat /etc/passwd | grep ftpuser – Steve Robillard Dec 31 '15 at 13:52
  • 2
    Have you tried useradd -g ftpgroup -s /sbin/nologin –d /dev/null ftpuser? You might need to use sudo as well as useradd typically needs root priviliges. – Phil B. Dec 31 '15 at 13:52
  • to add to what @PhilB.posted the if you look at the usage details the first line the options all come before the username (i.e.LOGIN) – Steve Robillard Dec 31 '15 at 13:54
  • @PhilB. I just tried with both /sbin/nologin and /etc/sbin/nologin but I have the same problem. I checked with the cat /etc/passwd | grep ftpuser if the user created but it failed – trelozakinthinos Dec 31 '15 at 14:06
  • Ok but did you put the username at the end of the useradd statement as I suggested? Useradd will be successful even if the login shell location is incorrect (you'll just have a boatload of trouble trying to login as the user :) ) – Phil B. Dec 31 '15 at 14:43
  • @PhilB. Yes I tried

    sudo useradd -g ftpgroup -s /usr/sbin/nologin –d /dev/null ftpuser

    and

    sudo useradd -g ftpgroup -s /sbin/nologin –d /dev/null ftpuser

    – trelozakinthinos Dec 31 '15 at 15:03
  • What happens if you run sudo useradd -D also what is output by which useradd – Steve Robillard Dec 31 '15 at 15:14
  • @SteveRobillard I manage to create user only with the command useradd jason. The useradd -D jason didn't work neither. – trelozakinthinos Dec 31 '15 at 15:24
  • no just useradd -D maybe with sudo – Steve Robillard Dec 31 '15 at 15:25
  • @SteveRobillard Sorry my fault. useradd -D returns GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel CREATE_MAIL_SPOOL=no – trelozakinthinos Dec 31 '15 at 15:38
  • and what about which useradd – Steve Robillard Dec 31 '15 at 15:39
  • which useradd returns /usr/sbin/useradd – trelozakinthinos Dec 31 '15 at 15:41
  • have you considered using adduser instead? though that may fail as well because adduser call useradd – Steve Robillard Dec 31 '15 at 15:43
  • stupid question but does the group already exist? This http://askubuntu.com/questions/345974/what-is-the-difference-between-adduser-and-useradd and the linked question on superuser may help – Steve Robillard Dec 31 '15 at 15:55
  • The group exists because when I give groupadd ftpgroup returns groupadd: group 'ftpgroup' already exists . Also I tried sudo adduser -g ftpgroup -s /usr/sbin/nologin –d /dev/null ftpuser and returns `Option g is ambiguous (gecos, gid, group) Option s is ambiguous (shell, system) adduser [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID] [--firstuid ID] [--lastuid ID] [--gecos GECOS] [--ingroup GROUP | --gid ID] [--disabled-password] [--disabled-login] USER Add a normal user

    adduser --system [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID] [--gecos GECOS] [--gro... `

    – trelozakinthinos Dec 31 '15 at 16:10
  • I also tried sudo adduser [--ingroup ftpgroup] [--shell /usr/sbin/nologin] [–-home /dev/null] ftpuser (without brackets as well) and it returns adduser: Only one or two names allowed. – trelozakinthinos Dec 31 '15 at 16:47

1 Answers1

1

Maybe you didn't notice (and I did have the same problem) but

useradd ftpuser -g ftpgroup -s /sbin/nologin –d /dev/null

has the - incorrectly before the d. I was able to notice this when trying it myself with my own raspberry pi (yes very annoying to notice that typo in an official help post of the raspberrypi page) so once you copy and paste it, replace that – before the d by the real -.

Problem side to side

–d | -d

If you change that it should work now. (or if you are too lazy just copy paste the fixed version that I placed below). I forgot to mention, in the raspberry you need sudo (root action) to create another user.

sudo useradd -g ftpgroup -s /sbin/nologin -d /dev/null ftpuser

OR

sudo useradd ftpuser -g ftpgroup -s /sbin/nologin -d /dev/null