Go interactive cli script to add a new Freebsd/Linux user with zfs dataset and appropriate permissions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zico 75f0ae86df changed module name and bumped version 1 month ago
.gitignore added build dir to gitignore and fixed app version 2 months ago
README.md update readme to new name, include linux 2 months ago
config.example.toml refactored user creation to different file, added options to config, skel dir instead of creating in script 2 months ago
go.mod changed module name and bumped version 1 month ago
go.sum added a toml config file, flag for config location, stopped echoing and printing password to output 2 months ago
main.go changed module name and bumped version 1 month ago
usercreate.go fix linux user create and change default config location to current dir 2 months ago

README.md

zfs-addnewuser


This is a interactive cli Go program to add a new user to FreeBSD or Linux. It assumes you already have a working zfs setup and want to create a new dataset for each new user. The user enters their username, password, and ssh key (all subject to validation checks). Zfs quotas are used to limit each user's home directory to a certain size.

The intended use case for this script is people connecting over ssh to a specific user; that user should be limited by the sshd config (Match to the user and ForceCommand to this script) to only run this script. As they are creating users and zfs datasets, they will need superuser permissions on the script.

The script now asks for a user password. If you intend to allow users to mount zfs datasets in their home directory without superuser permissions, you must set sysctl vfs.usermount=1.

The script expects extra files that should be copied to a user's home directory to be in the SkeletonDir. If an .ssh directory is not copied from the skel directory to the user's home, the script will create the folder

This has not been tested extensively, so please do your own testing if you choose to rely on it for important stuff.