Shell Creating users

Hi all,

I have created a post jailinstallation and I am strugling to create a user and add the user to a specific group..

So far I managed to workout that the script bellow will create a user and a group of same name.. user:user what I want is user:wpsftp
Code:
## create user and group
pw groupadd -q -n $user -g 1002
        echo -n '$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91' |\
                pw useradd -n $user -u 1002 -c "$user Live" -g $user -G wheel -s /bin/csh -d /home/$user -m -H 0
                chown -R $user:$user /home/$user
cat /etc/group
Code:
wpsftp:*:1002:

/etc/ssh/sshd_config
Code:
...
    Match Group wpsftp
    ChrootDirectory %h
    ForceCommand internal-sftp
    AllowTcpForwarding no
    X11Forwarding no
...
Could anyone please help
 
Code:
pw groupadd -q -n $user -g 1002
This creates a group with the same name as the user account. Which is not what you wanted.

Code:
user='user'
group='wpsftp'

pw groupadd -q -g 1002 $group

echo -n '$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91' |\
        pw useradd -u 1002 -c "$user Live" -g $group -G wheel -s /bin/csh -d /home/$user -m -H 0 $user

chown -R $user:$group /home/$user

The commands are a little complex but it's basically:
Code:
pw groupadd <options> <groupname>
pw useradd <options> <username>
 
Does the -G wheel add the user to the wheel group?
Yes. The -g sets the primary group, with -G you can add the user to additional groups. The primary group is mandatory, additional groups are optional.
 
Back
Top