ssh into multiple servers and tail -f
Hi there,
got a question about simultaneously running a script on multiple servers.. currently i have to run the following on two servers: Code:
tail -f /var/logs | grep error NOTE:i also need to login via ssh/pw..the passwords on both servers are the same. |
Use pssh. It's probably in your distribution's package repository.
|
Alternatively, if this is a long term need (i.e. not just a one-off), you might consider appointing one of your servers as a logging host. That would allow you to tail(1) - and report against - a set of logs on just that server.
|
not sure why you need to ssh into both at the same time (why not 1-by-1 ?)
not sure why you must use passwords (why not use ssh keys ?) anyways, i would do something like: Code:
ssh user1@server1 tail -f /var/logs | grep error && ssh user2@server2 tail -f /var/logs | grep error |
ssh-keys is recommended for this; you really shouldn't be putting passwd in a script, or consider ssh-agent.
If you MUST use passwds, consider Expect http://linux.die.net/man/1/expect. Another option if this is a regular requirement, can you get the remote machines to do this automatically eg triggered by cron or by an event, then email the results to you. |
To make your process quicker, and still log in to each server individually to run your command (paste in your terminal), you can try FastSSHer with your sshkey.
|
Quote:
How would i use ssh keys? would you know of a simple guide i can follow? I'm still pretty new to all this and a step by step guide would be helpful, thanks. and thanks to everyone else for their suggestions. |
If you do a web search for "automatic login ssh" you will find pages like this:
http://linuxproblem.org/art_9.html http://wp.uberdose.com/2006/10/16/ssh-automatic-login/ |
All times are GMT -5. The time now is 12:40 PM. |