Adding users
You can create user accounts on a Flatcar Container Linux machine manually with useradd or via a
Butane Config
when the machine is created.
Add Users via Butane Configs
In your Butane Config, you can specify many different parameters for each user. Here’s an example:
|
|
Because usermod does not work to add a user to a predefined system group, you can use
systemd-userdb
to define membership. Here’s the same example with userdb:
|
|
Add user manually
If you’d like to add a user manually, SSH to the machine and use the useradd tool. To create the user user, run:
|
|
The "*" creates a user that cannot login with a password but can log in via SSH key. -U creates a group for the user, -G adds the user to the existing sudo group and -m creates a home directory. If you’d like to add a password for the user, run:
|
|
To assign an SSH key, run:
|
|
Grant sudo Access
If you trust the user, you can grant administrative privileges using visudo. visudo checks the file syntax before actually overwriting the sudoers file. This command should be run as root to avoid losing sudo access in the event of a failure. Instead of editing /etc/sudo.conf directly you will create a new file under the /etc/sudoers.d/ directory. When you run visudo, it is required that you specify which file you are attempting to edit with the -f argument:
|
|
Add a the line:
|
|
Check that sudo has been granted:
|
|