WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: setting password though script  (Read 1819 times)

Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
setting password though script
« on: February 12, 2011, 01:41:01 AM »
Hi,

I want to change my password through a script:

tried this but it didn't work. Can anyone see the mistake I am making?

tc@box:/mnt/sda1$ echo '123asimov$$$' ; echo '123asimov$$$' | sudo passwd tc
123asimov$$$
Changing password for tc
New password:
Retype password:
Passwords don't match
passwd: password for tc is unchanged

Thanks.

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: setting password though script
« Reply #1 on: February 12, 2011, 02:07:50 AM »
You can see an example of how I did it in /etc/init.d/tc-config using chpasswd

 echo "$USER:$PASSWD" | chpasswd
10+ Years Contributing to Linux Open Source Projects.

Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
Re: setting password though script
« Reply #2 on: February 12, 2011, 08:25:17 PM »

HI that works great!


Still would be interested to know how to do this using pipes/redirectiohiln as I wish to use the same techniques for smbpasswd as well.

I saw a script somewhere that showed the password being redirected to the program from a file but cannot find it. It was not as simple as sudo smbpasswd -a user < passfile.txt

regards b1ackmai1er