LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-15-2004, 03:26 PM   #1
evilchild
Member
 
Registered: Sep 2003
Location: 127.0.0.1
Distribution: *bsd, solaris, gentoo
Posts: 86

Rep: Reputation: 15
Question 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
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
 
Old 07-15-2004, 03:47 PM   #2
SheldonPlankton
Member
 
Registered: Jun 2004
Posts: 129

Rep: Reputation: 15
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.
 
Old 07-16-2004, 12:47 AM   #3
evilchild
Member
 
Registered: Sep 2003
Location: 127.0.0.1
Distribution: *bsd, solaris, gentoo
Posts: 86

Original Poster
Rep: Reputation: 15
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?
 
Old 07-16-2004, 11:18 AM   #4
SheldonPlankton
Member
 
Registered: Jun 2004
Posts: 129

Rep: Reputation: 15
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.
 
Old 08-12-2004, 12:30 PM   #5
evilchild
Member
 
Registered: Sep 2003
Location: 127.0.0.1
Distribution: *bsd, solaris, gentoo
Posts: 86

Original Poster
Rep: Reputation: 15
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?

Last edited by evilchild; 08-12-2004 at 12:55 PM.
 
Old 08-12-2004, 01:18 PM   #6
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,790
Blog Entries: 1

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
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?
 
Old 08-12-2004, 10:48 PM   #7
SheldonPlankton
Member
 
Registered: Jun 2004
Posts: 129

Rep: Reputation: 15
you could use expect ... just google for it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
scp/ssh tail(multiple file) remote copy tpreitano Linux - General 1 08-22-2005 02:17 PM
Multiple Machines behind single Static IP - failing remote ssh Animalector Linux - Security 8 08-18-2005 06:01 PM
execute multiple ssh remote commands tom221 Linux - Newbie 2 01-28-2005 01:00 PM
executing multiple commands by ssh jpan Linux - General 1 10-22-2004 02:12 PM
Adding shell commands to hosts.deny and hosts.allow ridertech Linux - Security 3 12-29-2003 03:52 PM


All times are GMT -5. The time now is 07:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration