.gitignore | ||
config.example.toml | ||
go.mod | ||
go.sum | ||
main.go | ||
README.md | ||
usercreate.go |
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 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.