A scripting question
Hi,
I am still very new to scripting and learning. I have a very basic question. How do I run commands remotely. For example, if I am on server x and want to run a set of commands on server y and z, how can I do that without having to log on to each of them. Basic commands like looking for a user in /etc/passwd file in each server etc. Thanks. |
Most Linux systems use ssh. You can pass a command for execution on a remote system, without starting a terminal session. For example:
Code:
ssh someuser@somesystem grep somebody /etc/passwd |
Hi there,
Quote:
If you want to run commands (i.e. programs) on a unix-like machine, you have to log on to that machine - preferrably via ssh. That means, you need to have a user account on that host (which can be a generic one, of course). [X] Doc CPU |
Quote:
A way to send request is to, say, create or modify a file, and for that there should exist NFS mounts. Or remote hosts can listen on a port using sockets. |
Quote:
Thanks. The above command worked. Now my question is how can I do routine to multiple servers, possibly with one command. I know I can probably do ssh someuser@somesystem grep somebody /etc/passwd;ssh someuser@somesystem1 grep somebody /etc/passwd ; and so on .. but if there is a quicker way to do this that would be great. For example, I can have a file with a list of systems in it and then have a for loop read thru that file, one system at a time. I dont know how to put this into code, but I thought that might work? Thanks. |
|
The pssh (parallel ssh) command can perform the function you're looking for. It can send the same commands to multiple systems and report or collect to files the responses. It's available in most distribution's repositories.
|
All times are GMT -5. The time now is 11:15 AM. |