Change user password within bash script on Ubuntu/Debian

While creating a bash script to automate the configuration of a vhost and wordpress installation, I needed to automatically create an ubuntu user and assign the password from within the script without ANY user interaction.

I tried many different methods to no avail;  The only solution that worked for me was piping username:password into chpasswd:

  • echo “$usrn:$usrpwd” | chpasswd

source: http://www.ibm.com/developerworks/aix/library/au-chpasspwgen.html

If this article has been helpful, please consider linking to it or commenting.

Bookmark and Share

Post Author

This post was written by iainlbc who has written 13 posts on iainlbc.

One Response to “Change user password within bash script on Ubuntu/Debian”

  1. mahmudin ashar 10. Jul, 2010 at 12:32 am #

    nice article, simple and work for me. Thanks ..

Leave a Reply