How to setup SSH between 4 hosts ?

Hi,

I logged into h0011awe server. I am executing a script on this server which connects to other 3 hosts (h0022sam, h0033jar, h0044orc). In the script the command are like this
orapmon=`ssh $USR@$host ps -ef|grep -v grep|grep pmon`
I am using secured shell. How to setup that between these hosts which shouldn't ask me for passswords when i execute the script. My OS is Sun Solaris.

Thanks

  1. On the source server, run "ssh-keygen -t rsa" (for an RSA key; man ssh-keygen for alternate keys). Hit enter at each of the prompts. A file called "id_rsa.pub" will be located in your .ssh directory.

  2. Copy the id_rsa.pub file to the three (or more) target servers and append it to the target server's authorized_keys file, located in the .ssh directory.

Note: This isn't ideal WRT security since if someone gains access to the source server, they then have access to all the others.

You can also use ssh-agent. I haven't used it so I can't be much help there. Man should work though :slight_smile:

Carl

One way (although not incredibly secure,) is:

host-a$ ssh-keygen -t dsa 
 (When prompted to enter a password, just type enter for a blank password.)
host-a$ cat ~/.ssh/id_dsa.pub |ssh host-b cat > ~/.ssh/authorized_keys2
 (Note: you will be prompted for a password here, but from now on, it should "trust" you.)
host-a$ ssh host-b ls -l
 (Assuming all went well, you should get the directory listing from host-b without being prompted for a password.)

Now, the above assumes some things, like you're using ssh2, your admin hasn't disabled you from doing that, that you are not breaking policy by doing that, etc.