automating username / password entry


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting automating username / password entry
# 1  
Old 05-12-2009
automating username / password entry

I have a database that contains a list of server names, and the password for the root user on several servers (100+). I need to verify the passwords for each of the servers in an automated fashion because the database continues to grow. All of the users that I'm going to test are ROOT. I can't use keys and I can't necessarily use Perl because not every server has it installed and the ones that don't...i can't install it on them. So I was considering using the EXPECT command to get this done.

I have a file that looks like this:
server1 password
server2 password
etc...

What I want to happen (in my head this is how I see it working anyway) is that I run the script and the script reads my file (named login_pass.txt), logs into the 1st server and when prompted it supplies the associated password. If the password fails I would like to have the failures outputed somehow so that I can make a note of them and eventually go back and fix them.

Here is the code that I have come up with so far...
Code:
#!/bin/bash
#!/usr/bin/expect -f
FILE=login_pass.txt
HOSTS=`awk '{print $1}' $FILE`
PASS=`awk '{print $2}' $FILE`
for x in $HOSTS;do
expect "root@$HOSTS:"
ssh -C -q root@$HOSTS "hostname;date /"
#expect "root@$HOSTS:"
send -- "$PASS \r"
send -- "\r"
done
expect eof

I'm really new to scripting in unix so I know I'm doing something wrong and hopefully something easilly fixed. Can someone help me out on this? Also if there is a better way to do this please let me know as I'm open for suggestions.

Thanks for the help!
# 2  
Old 05-16-2009
I'm not too good with expect/send, so assuming that part is correct, you just need to modify the part that reads in the user/pass variables:
Code:
cat $FILE |
while read HOST PASS ; do
   ...
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automating UNIX/Solaris password resets

Hi, we are running solaris 5.10 and looking for solutions to automate password resets? Plz assist. Thanks, Sridhar (6 Replies)
Discussion started by: chvgms
6 Replies

2. UNIX for Advanced & Expert Users

Automating Password reset without shell usage

Our application runs on AIX and the users of the application do not have a way to land at the prompt/shell by any means. When they login to the box, the application opens up directly. I would like to know of a way to automate the password reset process for these user ids, without them having to... (2 Replies)
Discussion started by: ggayathri
2 Replies

3. UNIX for Dummies Questions & Answers

How do you reset username/password

Picked up a 3b2 running System V. Works fine, but it requires a username and password. Is the username "root" or "sysadm"? How do I find out and how to I reset it or bypass it? Thanks. (2 Replies)
Discussion started by: TanRuNomad
2 Replies

4. Shell Programming and Scripting

Username and password

Hi I am new to using unix and am struggling with a script i am writing. What i am trying to do is get a user to enter a username, check the original file i created with username and pin to see if their is a corresponding entry. Next ask the user to enter the pin and see if this matches... (5 Replies)
Discussion started by: somersetdan
5 Replies

5. UNIX for Advanced & Expert Users

Automating Interactive password change

I have written the below scripts . ldap_pwd_prompt.ksh #!/usr/bin/ksh passwd -r ldap interactive_pwd_change.exp #!/usr/local/bin/expect set timeout 10 set curpass set newpass spawn ./ldap_pwd_prompt.ksh expect "Enter existing login password:" send "$curpass\r" expect "New... (6 Replies)
Discussion started by: dr46014
6 Replies

6. UNIX for Dummies Questions & Answers

How can i hide username/password

hi all, i run sqlplus command on unix(HP-UX) like "sqlplus username/password@serverA @deneme.sql" but when someone run "ps -ef | grep sqlplus", it can see my username and password :( How can i hide username and password. thanx. (1 Reply)
Discussion started by: temhem
1 Replies

7. Shell Programming and Scripting

automating ssh session with password

Hi Can anyone help me in automate a ssh session with password using shell script (7 Replies)
Discussion started by: raghav288
7 Replies

8. Shell Programming and Scripting

username password in script

Can we write a script to telnet to a unix server from unix with the username and password hardcoded in the script?? something like ssh a@b -p password ??? (5 Replies)
Discussion started by: roshanjain2
5 Replies

9. UNIX for Dummies Questions & Answers

Automating password change

Hi, I'm trying to create a shell to change some user password with random string. I've tried to use stdin redirection to supply the new password by a response file: passwd theuser < respfile but I continue to be prompted for supplying pwd via console keyboard. Can you help me to... (2 Replies)
Discussion started by: nisant
2 Replies

10. Shell Programming and Scripting

automating password ?

Hi all, I want to write a script which logs into a database (DB2). To do this i need to have a password. This will be done lots and lots of times, so i need to modify the script to automate the response to the password request. How do i this, because at present i do the following: db2 connect... (3 Replies)
Discussion started by: Liamo
3 Replies
Login or Register to Ask a Question