Login to multiple host without using Expect


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Login to multiple host without using Expect
# 1  
Old 02-07-2012
Error Login to multiple host without using Expect

Hello ,

I have a problem which involves a set of command should be executed on remote host and output should be stored in a file. But due to security reason I can not use expect to enter the password and its not possible to create password less login for multiple user to do the same thing and we can not set one user to do this task.

I have to write only shell script to do this . Perl/Python is not suggested in my environment.

However perl/python can be taken under consideration if it doesn't involves us to install any extra module. Perl/Python script should not require any extra module which needs to be installed or does not comes with the default installation.

Let me know if any one have any idea about it.

Smilie
# 2  
Old 02-07-2012
So, you intend to type in the password every time for each server?

--ahamed
# 3  
Old 02-07-2012
Yeah as of now it seems to be that only. But is there any way that can be achieved? Is there any way to write my own expect function?

If that is possible I can do it . But I am not that smart in scripting yet.

Thank you
# 4  
Old 02-07-2012
This can give you a start...
Code:
#!/bin/bash
user="admin"
hostlist="127.0.0.1 127.0.0.2 127.0.0.3"
for host in $hostlist
do
        echo $user@$host >> /tmp/log
        ssh $user@$host "ps" >> /tmp/log
done

The output is stored in the /tmp/log file. It will ask for password and you need to enter it!

--ahamed
# 5  
Old 02-08-2012
Thanks but , is there a way to write a function which should act like expect or Net::SSH.

Smilie
# 6  
Old 02-08-2012
What do you mean by "act"?? Please elaborate.

--ahamed
# 7  
Old 02-08-2012
Without expect you can try with as below ... But this is working on Solaris serves only ...
Code:
# echo -e "ur-psw" | rsh <seever-ip" 


-- Shirish Shukla

Last edited by Franklin52; 02-08-2012 at 07:16 AM.. Reason: Please use code tags for code and data samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Expect /bash, 2 ssh login users

HI all i need to connect to about 900 cisco routers and switch to do some configs changes. the issue i am having is that half the devices have one set of username and password and the other half have another username and password. From expect or bash script i can ssh into a device and make... (1 Reply)
Discussion started by: quintin
1 Replies

2. Shell Programming and Scripting

FTP File to Multiple Host

I need to ftp a file to several servers. I have seen a lot examples on how to ftp several files from a host, none for what I need. I'm sorry if this has already been answered, hopefully someone can point me in the right direction. I'm very new to scripting. Thanks. (3 Replies)
Discussion started by: slqtech
3 Replies

3. Shell Programming and Scripting

Expect script ssh passwordless login

how can i use an expect script to do a passwordless ssh login and run a script on a bunch of remote hosts? I do not want to use public key authentication as this would require me to setup the keys on the clients etc.... (2 Replies)
Discussion started by: tdubb123
2 Replies

4. Shell Programming and Scripting

Login to remote host and execute commands

Hi, i want to write script where it will login into 50 hosts and if login is successful it print message "login to host1 is successful" if not it should print message "Not able to login to host1". once connection to the host is succesful it should fire df command to check filesystem if df is... (3 Replies)
Discussion started by: amru8810
3 Replies

5. Shell Programming and Scripting

Expect script to execute a script on a remote host

Hi, I am new to the expect scripting. I have this expect script as below : spawn ssh remote_server -l id set pass "12345" set opt "s" expect "Password:" {send "$pass\r" ; } expect "*ENTER*" {send "Enter\r"; exp_continue } expect "Please select option :" {send... (2 Replies)
Discussion started by: curt137
2 Replies

6. Shell Programming and Scripting

Plz help me using expect script for remote host

I am newbie in Unix and Expect script, so please help me :( I'm using expect script for remote another host: #!/usr/bin/expect -f set timeout 10 spawn ssh -l root 10.120.18.4 expect "password:" send "password\r" expect "@" interact And now how can i use expect script for access mysql... (2 Replies)
Discussion started by: wormym
2 Replies

7. Shell Programming and Scripting

Expect get host ip

Hi, I am trying to get the users ip address as an expect variable Bash (works): /sbin/ifconfig | grep 'inet addr' | grep -v 127.0.0.1 | head -1 | /bin/cut -d: -f2 | /bin/cut -d' ' -f1 Expect (fails): set HOST_IP However I am getting: grep: addr': No such file or directory Is there... (2 Replies)
Discussion started by: rpowell86
2 Replies

8. UNIX for Dummies Questions & Answers

how to handle multiple apps on host?

So, I'm going to install Oracle DB within my Suse host... Also, I would like to run Virtual Box and Tomcat.. ok, tomcat is going to be runnable app that will start at boot.. but, how to handle Oracle and virtual box? I would like to have an Oracle under it's own user, and to be able to use... (0 Replies)
Discussion started by: bongo
0 Replies

9. Shell Programming and Scripting

rsh login to host with password

Hello, iḿ rather new to writing scripts in UNIX so i thought this would be a good start. I need to write a script that can login to different hosts in a standalone network. That means there are no connection to Internet etc. I need to collect some data on the hosts, and they have different... (11 Replies)
Discussion started by: topy
11 Replies

10. Shell Programming and Scripting

change password for multiple host

1-How can i change root password of 5 Fedora 11 machines (server1 server2 server3 server4 server5) with a single script , for example make password : 123456 NB. from server1 i can via ssh connect to the others machines without a password Please help. (3 Replies)
Discussion started by: chang-lee
3 Replies
Login or Register to Ask a Question