to all the Cloud-init experts:
Recently, I've been trying to play around with cloud-init's capabilities for user account creation and management.
I wanted to forbid root ssh login and to create another sudo user that needs no password for sudo.
I do get the desired result, but I do not know how is it implemented.
Sample config.cfg:
users:
- name: root
# lock_passwd: false
- default
- name: user_name
gecos: Non-root User
primary_group: nr_user
groups: nr_user,sudo,wheel
lock_passwd: false
passwd: $6$rounds=4096$e0Ju.HuWxqWs....JeEzX/XGGave2jhi1
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
disable_root: true
disable_root_opts: no-port-forwarding,no-agent-forwarding,no-X11-forwarding
I should typically restrict root ssh login through /etc/ssh/sshd_config
, changing: PermitRootLogin yes
to PermitRootLogin no
.
I would typically add a line, like this: user_name ALL=(ALL) NOPASSWD:ALL
to /etc/sudoers
, if I want to have a sudoer that needs not to enter password every time.
But I see no changes like this.
On top of that the very custom message that root ssh is disabled and anther user should be used, makes me wonder how is it achieved? Does cloud-init spin a module that is monitoring for the usage of users and applying the settings on the fly?