Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 765
  • Last Modified:

Knoppix set passwd redirect stdin from file

I am running knoppix kernel 2.6.17 booting from a USB key.  I would like to set a password for the root account from my startup script.

I have created a file called passwdtwice, and run the following: passwd <passwdtwice
The passwdtwice file contains:
test123
test123

However, everytime I run the command it says the passwords do not match.  They do!  I ensured there is a CR after each line too.

Any idea how to make passwd take input from stdin directed from file?  (There is no -stdin option for passwd in this version of knoppix).?

Help!
0
Jason Dupont
Asked:
Jason Dupont
  • 2
1 Solution
 
ravenplCommented:
Usually one uses expect script for such job.
But as for You maye it's better if You set the password by hand, then remember the password value from /etc/shadow and create script

usermod -p 'saved_passwd' root # where saved_passwd should look like $1$asas$sfgjhgjscvdgjsc

This way the password is not availabe from the script, therefore the solution is safer.
0
 
Jason DupontAuthor Commented:
How do I create the encrypted password (for use with usermod)?
0
 
ravenplCommented:
Just change the password with 'passwd' tool, then grab the encoded password from /etc/shadow file
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now