Pipe Actual Password to passwd

Hello,

I have a problem. As ldap admin, i have a account with a stored password in passwd (means local). This password must be changed every 30 days.
Now i want execute "passwd" without prompt for the actual password.
I will only typie in the new password.
On Ubuntu i solve this with the following command:

echo "<oldPWD>" | passwd -r files <USERNAME>--stdin

but the "--stdin" doesn't worked on solaris bash.

how can i solve this?

  1. It's not a problem that old PW ist after executing stored in history. Because after execution the password is old and not usable

  2. i have no root access.

  3. i can't install a additionally Package (but i can use a local script)

  4. yes, I'm lazy but this are 35 Servers and it's annoying to type this password 35 times.

thanks in advanced

That would not be possible.

You will need to use expect

Best regards
Peasant.

1 Like

ah cool,

with this script is worked correct

#!/<path>/expect
set oldpass [lindex $argv 0]
set newpass [lindex $argv 1]
spawn passwd
expect "Enter existing login password:" {send "$oldpass\r"}
expect "New Password:" {send "$newpass\r"}
expect "Re-enter new Password:" {send "$newpass\r"}
expect {
  "password successfully changed for flohfeld" {puts stdout "\nsuccessful changed"}
  default {puts stdout "\nERROR!"}
}
1 Like