Lazy create sudo user
Creating users on Linux is trivial, but creating a user with sudo rights and no password confirmation when using sudo is not.
The script must be run under user root.
Tested on Ubuntu, Debian, CentOS and RHEL.
#!/bin/bash set -xe USERNAME="kami" useradd -m -s /bin/bash $USERNAME usermod -aG sudo $USERNAME || true # for Debian/Ubuntu usermod -aG wheel $USERNAME || true # for CentOS/RHEL # this change is better done manually using "visudo -f /etc/sudoers" echo "${USERNAME} ALL = NOPASSWD : ALL" >> /etc/sudoers
That's all, folks!
Tweet