Skip to content

Use Sudo Without Password Prompt in Scripts

View on Twitter

💡 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:

"youruser ALL=(ALL:ALL) NOPASSWD: ALL"

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.

Download the VPS Security Cheatsheet

Use this FREE security cheatsheet to not miss a step when securing your VPS.

A preview of the VPS Security Cheatsheet.

You'll also get tips on building scalable Node.js applications about twice a month. I respect your email privacy. Unsubscribe any time.

You might also like
Improve Nginx Performance: Direct File Transfers Read tip
Run Locally Installed NPM Library Read tip
Mapping of HTTP Status Messages in Node.js Read tip