connecting servers using shell script

Hi ,
I have three linux servers. I want to login from one server and check some status in the other server.

How to connect other server from one server using shell script.
Can anyone advice on this?

Thanks,
Chelladurai.

$ ssh user@hostname "command_to_run_on_remote_host"

ssh - Linux Command - Unix Command

  1. Generate ssh keys on client side (host from which You'll run script).
cd
mkdir .ssh && chmod 700 .ssh
ssh-keygen

Leave all in defaults (hit enter, enter, enter...), don't enter any passphrase.
2. Copy file id_rsa.pub to remote server (repeat for all servers You want to use).

scp ~/.ssh/id_rsa.pub user@remote.host
  1. Login on remote host and add key to your authorized_keys:
ssh user@remote.host
mkdir .ssh && chmod 700 .ssh     #ignore errors if occure here
cat id_rsa.pub >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys
  1. Logout from remote server
  2. Try logging to remote server again, should work without asking for pass:
ssh user@remote.host

In script use:

ssh user@remote.host "uptime"

This will execute "uptime" on remote host and return all STDOUT to local console.

Hi All,
I need to single script to connect the server and check one particular script is running or not. I want in shell script maode.

If i run the script, it will connect two or three servers and get back with the status of the server's script.

Thanks in advance

What did you try so far, where are you stuck? This is a support forum, not a freelancer/project forum.