2

My account was copied from 1 to a big number of hosts. On every host on 1-st login I get:

WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user dmitresso.
Changing password for dmitresso.
(current) UNIX password:

Trying to automate this proccess I'm writing script, where I've following progress in a part of changing password:

#! /bin/bash

username=dmitresso
hostname=aaa
pass=bbb
newpass=ccc

sshpass -p "${pass}" ssh -tt -o StrictHostKeyChecking=no ${username}@${hostname}

I've tried echo -e "${pass}\n${newpass}\n${newpass}" | sshpass -p "${pass}" ssh -tt -o StrictHostKeyChecking=no ${username}@${hostname} but it gives my passwords as output before dialogue starts:

WARNING: Your password has expired.
You must change your password now and login again!
bbb
ccc
ccc
Changing password for user dmitresso.
Changing password for dmitresso.
(current) UNIX password:

and another variations.

Many posts tell about similar situations, but there:

  1. Using passwd on local machine or passing passwd with arguments through ssh where someone initiates password changes on his own;
  2. Also without any ssh;
  3. With expect I can't use (it's not installed, I have no root)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.