script not working as intended for password


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script not working as intended for password
# 1  
Old 06-04-2008
Error script not working as intended for password[SOLVED]

Hi

I have a script which uses expect and I run it on solaris 10 to set a common password for all users. I run it as `./script password` but when I tried to log into the system then I do not really have to type password, pressing ENTER on keyboard logs the user into system. (ssh)

This below is script and I feed it with a file with user names.


Quote:
#!/bin/ksh

ChangePasswd()
{
/usr/local/bin/expect <<EOF
set newpassword [lindex $argv 0]
spawn passwd $user
expect "New Password: " ## not expect "password:"
send "$newpassword\r"
expect "Re-enter new Password: " ## not expect "Re-enter"
send "$newpassword\r"
expect eof
EOF
}
#while read -p "Enter Userid:" user
while read user
do
if [[ $user != '' ]];
then
ChangePasswd $user
fi
done <ab
################### ab is file with user names

Last edited by upengan78; 06-05-2008 at 03:53 PM.. Reason: SOLVED
# 2  
Old 06-05-2008
any one ?well atleast give me a ready solution on setting passwords for large users either password = userid or password = common for everyone

I would make the users change passwords at first login later, which need not be part of script.just need to set password easily.


Also if please remember the script will be run on solaris 9 or 10 OS and not on Linux Smilie

Thanks
# 3  
Old 06-05-2008
Smilie I found it myself Smilie

Quote:
#!/bin/ksh

ChangePasswd()
{
/usr/local/bin/expect <<EOF
spawn passwd $user
expect "New Password: "
send -- "$2\r"
expect "Re-enter new Password: "
send -- "$2\r"
expect eof
EOF
}
#while read -p "Enter Userid:" user
while read user
do
if [[ $user != '' ]];
then
ChangePasswd $user $1
fi
done <ab
## ab file has the list of users whose password I am changing

I run the above script as ./script <password I want>

that sets the password for all users to what I want ! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Password Less Authentication not Working After Giving Full Permission

Hello Team, Please help me to solve my Problem, By mistake, I give full permission to /(root) directory. by using the following command "chmod -R 777 /" after this, the client asks for the password to login via ssh. Before that, I an able to Login without a password. Please help me to retrieve... (5 Replies)
Discussion started by: Shubham1182
5 Replies

2. Solaris

Solaris 10 - password complexity not working

I have been trying to enable password complexity variables on Solaris 10 by editing the /etc/default/passwd file but none of my changes are taking effect (I'm still able to set passwords that violate the rules I am trying to implement). I've tried an O/S reboot after the changes but that had no... (6 Replies)
Discussion started by: triggerhippie
6 Replies

3. UNIX for Dummies Questions & Answers

Ssh command without password - Not working

Hi, I have followed the below commands for key generation and ssh from one server to another with user mqm cd /var/mqm/.ssh mqm@A:~> ssh-keygen -t rsa <public key creation> mqm@A:~> ssh mqm@B mkdir -p .ssh mqm@B's password: <entered_password> mqm@A:~> cat /var/mqm/.ssh/id_rsa.pub | ssh... (4 Replies)
Discussion started by: Anusha M
4 Replies

4. Shell Programming and Scripting

Cronjob not working as intended

I have a shell script that I have scheduled using cron using a command: 0 10 * * * /directory/Script.sh > /directory/log/output.log The script is scheduled to run at 10 AM everyday. The script executes but produces output files only with headers, no content is there. The script produces... (11 Replies)
Discussion started by: Palak Sharma
11 Replies

5. Shell Programming and Scripting

sftp using password not working in unix

Sorry to post this thread as it has been asked several times. But my question is that I need to write a shell script to transfer a file from machine A to machine B using sftp. I generated pvt-pub key pair and put pub key in machine b and lso make the pub file's permision 600. .ssh directory... (1 Reply)
Discussion started by: vsachan
1 Replies

6. Shell Programming and Scripting

Password-less RSA Authentication not working

Hello Friends, I know this issue has been raised many times and hence I tried every resolution provided in the forum before I posted this issue again. My Password-less RSA authentication was working fine for quite some time. Whenever the remote server password used to change I used to re-do... (5 Replies)
Discussion started by: mehimadri
5 Replies

7. Solaris

Solaris 9 Reset Password - boot cdrom -s not working

Boot device : /pci@1f,4000/scsi@3/disk@0,0:a File and args: -s cdrom SunOS Release 5.9 Version Generic_118558-11 64-bit (6 Replies)
Discussion started by: agummad
6 Replies

8. Shell Programming and Scripting

how to change root password using shell script with standard password

Hi Friends. I am new to scripting now i want to change the root password using the script with standard password. which is the easy scripting to learn for the beginner, Thanks in advance. (2 Replies)
Discussion started by: kurva
2 Replies

9. Forum Support Area for Unregistered Users & Account Problems

emailed reset password is not working

Well, I get this email - Hello, You have requested to reset your password on The UNIX Forums forums because you have forgotten your password. If you did not request this, please ignore it. It will expire and become useless in 24 hours time. To reset your password, please visit the... (1 Reply)
Discussion started by: zyx
1 Replies
Login or Register to Ask a Question