Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a system image which uses a default password for root. This should be changed, though I have a feeling not all users do this.

I know I can test login with pamtester:

# pamtester system-auth root authenticate
Password:

It asks for the password on the command line. I want to automate this. Can this be done?

share|improve this question
up vote 0 down vote accepted

Yes, by using the Expect scripting language.

share|improve this answer

Check for the hash in the /etc/shadow file. You already have the hash, since it's part of your image. Just make sure the root password hash is different.

share|improve this answer

A here-document does the trick as well:

testparm ... << eof
`echo $password`
eof
share|improve this answer
    
It is not really clear to me, how does it work. I suggest to elaborate your answer. – peterh Jun 19 '15 at 15:43

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.