Go interactive cli script to add a new Freebsd/Linux user with zfs dataset and appropriate permissions.
Go to file
zico e1f3f310d3 bump version to v0.6 2023-01-15 03:55:12 -06:00
.gitignore added gitea-pakage-client conf file to gitignore 2023-01-15 03:17:47 -06:00
README.md update readme to extrafiles language 2023-01-15 03:51:01 -06:00
config.example.toml changed skeletondir to extrafiles, add check for if user already exists 2023-01-15 03:20:39 -06:00
go.mod changed module name and bumped version 2022-10-15 15:37:58 -05:00
go.sum added a toml config file, flag for config location, stopped echoing and printing password to output 2022-10-01 01:47:15 -05:00
main.go bump version to v0.6 2023-01-15 03:55:12 -06:00
usercreate.go implement change from skeletondir to extrafiles, chmod user home to user in golang way 2023-01-15 03:24:26 -06:00



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 listed, with their full path, in the ExtraFiles array in the config file. If a .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.