Skip to content

Use Sudo Without Password Prompt in Scripts

💡 Using a non-root user and requiring a password for sudo is a security best practice. However, in scripts you often need to use sudo without a password.

👉🏼 Run:

➡️ sudo visudo

And add this line to "/etc/sudoers" to disable password req:


To allow a user named ansible to use all sudo commands without a password, add ansible ALL=(ALL:ALL) NOPASSWD: ALL in /etc/sudoers file.
A preview of the VPS Security Cheatsheet.

Download the VPS Security Cheatsheet

No spam! 🙅🏻‍♀️ Unsubscribe at any time.