1

How to catch expired (own) password from ssh, from non-root account ? Expect is not installed on target servers.

I need to catch two states with single command:

  1. password is expired → when you login, you immediately need to type current password and two new passwords.

  2. password is ok → only need to change pwd. It can be done with

    printf "%s\n" oldpass newpass newpass | passwd
    

Something like

ssh user@host `if [[ pwd=expired ]]; then printf "%s\n" oldpass newpass newpass; else printf "%s\n" oldpass newpass newpass | passwd; fi`

I need to use it with Ansible, it should be simple.

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.