Quantcast
Channel: IDM Rockstar – Identity Management Blog
Viewing all articles
Browse latest Browse all 30

Quick’n’Dirty: Secure-ish way of executing sudo in shell scripts

$
0
0

I have a need a lot of times to execute sudo wrapped commands in shell scripts that I use for automating tedious tasks, like installing OIM =).

The kicker is that sometimes, I need to run commands as root. Here’s the quick and dirty way I accomplish that without divulging the passwords:

#! /bin/bash
read -s -p "Enter Password for sudo: " sudoPW
echo $sudoPW | sudo -S yum update

This way the user is prompted for the password (and hidden from terminal) and then passed into commands as needed, so I’m not running the entire script as root =)

If you have a better, way, I’d love to hear it! I’m not a shell scripting expert by any means.

Cheers!

.: Adam


Viewing all articles
Browse latest Browse all 30

Trending Articles