Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to implement an automated root password change for our Linux boxes. I'm generating a hash in the script since users will be able to see the contents of the script.

I found that you can pass a hash with the usermod utility. However, I'm running into a variable substitution issue as seen below.

Example:

# usermod -p $1$0J8av/8N$LIKB2G56XJn2IXp0XzERo1 root

# grep root /etc/shadow
root:-bashJ8av/8N:15709:0:99999:7:::
share|improve this question

1 Answer 1

up vote 4 down vote accepted

Surround the password on the usermod command with single quotes '' or escape the $ with '\$'

Like this

# usermod -p '$1$0J8av/8N$LIKB2G56XJn2IXp0XzERo1' root

or

# usermod -p \$1\$0J8av/8N\$LIKB2G56XJn2IXp0XzERo1 root
share|improve this answer
    
Thanks, the single quotes worked. I was trying double quotes. –  kernelpanic Jan 4 '13 at 15:06
    
Double quotes, as you noticed, still allow for variable interpolation. Single quotes on the other hand, don't. –  coredump Jan 4 '13 at 15:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.