Knoppix set passwd redirect stdin from file

Posted on 2007-08-10
Last Modified: 2013-12-16
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:

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).?

Question by:Jason Dupont
    LVL 43

    Accepted Solution

    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.

    Author Comment

    by:Jason Dupont
    How do I create the encrypted password (for use with usermod)?
    LVL 43

    Expert Comment

    Just change the password with 'passwd' tool, then grab the encoded password from /etc/shadow file

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
    Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now