0

I'm trying to write a script that logs in a user over SSH and than changes that user's password. The line of code I currently use for that looks like the following:

sshpass -p $password ssh $user@$ipadress "echo $user:$password_new | chpasswd"

It always throws several errors at me. Is my approach even correct?

I've already tried without the last part of the line, which looks like this:

sshpass -p $password ssh $user@$ipadress

But that also gives me the following error:

SSHPASS searching for password prompt using match "assword" SSHPASS read: SSHPASS read: $user@$ipadress's password: SSHPASS detected prompt. Sending password. SSHPASS read:

Permission denied, please try again. SSHPASS read: SSHPASS read: $user@$ipadress's password: SSHPASS detected prompt, again. Wrong password. Terminating.

What am I missing?

EDIT: I just realized that chpasswd is not installed on the remote machine, that partly explains the errors. So why is sshpass giving me errors then?

0 Answers0