Friday, April 17, 2020

sudo without password on linux

To access sudo, the user should be with admin rights/sudoers group.

On centOS:
useradd ansible -G wheel

this will add "ansible" user to admin group.

if you want to set password, use: passwd ansible

After above steps, when you run:  sudo su -
it will start sudo prompt but with password.

So, to skip password, run

visudo

It will open the sudoers file in default editor.

Add line:

ansible ALL=(ALL) NOPASSWD: ALL

Then, you can run below without password prompt.Which can be used for automations.
sudo su -  (or) sudo -i

No comments:

Post a Comment