LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   remote ssh commands on multiple hosts (http://www.linuxquestions.org/questions/linux-software-2/remote-ssh-commands-on-multiple-hosts-205490/)

evilchild 07-15-2004 03:26 PM

remote ssh commands on multiple hosts
 
I, looking for a tool that use ssh, to login on multiple hosts specified in a file or command line, and execute a command or list of commands. And would need to some how have store the password, so the whole process is not interactive, So this program will be entered in a simple shell script that is called from a form button from web browser.

I once knew of a program that did precisely as i wanted, but can't recall what it was called :confused:
I have searched all over google for some thing of this nature, and haven't had any luck. Does any one know where i can find some thing like this?

I what I'm looking for can be done in Perl using Net::SSH but, I'm not familiar with Perl, enough to write such a program on my own.

Any Response, would be appreciated
Thanks

SheldonPlankton 07-15-2004 03:47 PM

You could setup public key authenication for your ssh sessions. (http://cfm.gs.washington.edu/securit...client-pkauth/)
As far as iterating over host and commands just write a shell script ...

bash-2.05b$ ./test.sh hosts cmds
ssh maple "ls"
ssh maple "pwd"
ssh maple "hostname"
ssh oak "ls"
ssh oak "pwd"
ssh oak "hostname"
ssh pine "ls"
ssh pine "pwd"
ssh pine "hostname"
bash-2.05b$ cat test.sh
#!/bin/sh

hosts=$1
commands=$2

for host in `cat $hosts`
do
for cmd in `cat $commands`
do
echo "ssh $host \"$cmd\""
done
done
bash-2.05b$ cat hosts
maple
oak
pine
bash-2.05b$ cat cmds
ls
pwd
hostname
bash-2.05b$

And you'll have to have a cgi set up on you web server if you want to be able execute this script via a browser.

evilchild 07-16-2004 12:47 AM

since the script would be called by from the web-browser, wouldn't it run a user nobody, so where would the private key be stored?

SheldonPlankton 07-16-2004 11:18 AM

On my system ...

bash-2.05b$ finger nobody
Login: nobody Name: Nobody
Directory: / Shell: /sbin/nologin
Never logged in.
No mail.
No Plan.

... so the default location of the private key would be /.ssh and the ssh command would have to use -l user_with_a_shell option to work.

evilchild 08-12-2004 12:30 PM

in this thread i forgot to ask how can i key the passphase, and not have to enter it most of the time
?

Does any one know some thing that works similar to perl's net-ssh from the shell?

Hangdog42 08-12-2004 01:18 PM

Quote:

in this thread i forgot to ask how can i key the passphase, and not have to enter it most of the time
I think the trick here is to not use a passphrase when you generate the key. Then you never have to enter a passphrase. This does mean the system is a touch less secure, but there really isn't an alternative if you wan't to completely automate a task over ssh.

Quote:

Does any one know some thing that works similar to perl's net-ssh from the shell?
Um, doesn't ssh itself fill this role?

SheldonPlankton 08-12-2004 10:48 PM

you could use expect ... just google for it.


All times are GMT -5. The time now is 11:14 AM.