Hi,
I could like to change my remote system user password. Could you please guile me,
If you have any existing scripting there. please let me know
Thanks & Regards,
Mani
Hi,
I could like to change my remote system user password. Could you please guile me,
If you have any existing scripting there. please let me know
Thanks & Regards,
Mani
You may be able to use expect which isn't standard unix but a commonly installed tool from Expect | Free Development software downloads at SourceForge.net That may help, but after that it depends on your OS.
How you you plan to authenticate to the remote server? Is this ssh or rsh/remsh?
Some more details would be useful to give us a starting point.
Robin
Liverpool/Blackburn
UK
You can put in your remote script something like this:
echo user:test | chpasswd
This will set for "user" password "test"
Kind regards,
I would like to go remote server through ssh.
Save the first column of the file host_password_user.txt below to ipaddr.txt, the second column to password.txt and the third column to user.txt
ipaddr1 password1 user1
ipaddr2 password2 user2
ipaddr3 password3 user3
then invoke the script change_passwd.sh below
#!/bin/bash
mapfile addr < ${1}
mapfile pass < ${2}
mapfile user < ${3}
for((i=0; i<${#addr[@]}; ++i)); do
ssh ${addr} "echo '${pass}' | passwd --stdin '${user}'"
done
this way
bash change_passwd.sh ipaddr.txt password.txt user.txt
I don't wonder your intelligence what the file host_password_user.txt stands for!
./pwd.sh: line 3: mapfile: command not found
./pwd.sh: line 4: mapfile: command not found
./pwd.sh: line 5: mapfile: command not found
I got above error msg during the script run. Any tips ?
mapfile is available in bash >= 4 only.
I am not understand what you are trying to say... And also i feel that is it possible reset password through shell script...
Try using expect for this kind of problem.
Please note : You might need to change this script depending on the Unix flavor you use.
#!/usr/bin/expect -f
set ipaddress [lindex $argv 0]
set password [lindex $argv 1]
set timeout 10
spawn ssh -o StrictHostKeyChecking=no -o Batchmode=yes root@$ipaddress
expect {
blah@blah# {
send "passwd\r"
expect {
New Password: {
send "$passwod\r"
expect {
Reenter New Password: {
send "$password\r
}
}
}
}
exp_continue
}
"Password changed." {
return 0
}
timeout {
return 1
}
}
expect eof