0

I have one master and four slave computers. I generated rsa public/private key on master PC. Then I copied publickey (id_rsa.pub) to slave machines as authorized_keys.

It doesn't ask password when I invoke SSH like this on master PC's terminal:

ssh –o UserKnownHostsFile=/dev/null –o StrictHostKeyChecking=no hduser@slave1 

I wrote this script to automatically login slave machines without asking password.

SERVER_LIST=`cat /home/hduser/slaves` # slave1, slave2 ...
USERNAME=hduser
for host in $SERVER_LIST; do 
ssh –t –o UserKnownHostsFile=/dev/null –o StrictHostKeyChecking=no -l ${USERNAME} ${host}; 
done

SSH is asking slaves passwords when I use this script. I'm getting this message when use SSH with -vv option:

-vv option

I changed permissions on master PC and slave PC.

sudo chmod 700 -R ~/.ssh
sudo chown hduser ~/.ssh

It still asking password. What am I missing? How can I fix it?

2 Answers2

0

Try to use the -i argument. From the man:

-i identity_file
         Selects a file from which the identity (private key) for RSA or
         DSA authentication is read.  The default is ~/.ssh/identity for
         protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for pro-
         tocol version 2.  Identity files may also be specified on a per-
         host basis in the configuration file.  It is possible to have
         multiple -i options (and multiple identities specified in config-
         uration files).

Then you can specify the key to use for each host.

peperunas
  • 214
  • 1
  • 3
  • -i option works too. I pointed hduser ssh directory and it works without copying private key to root ssh directory. I changed this line: ssh –t –o UserKnownHostsFile=/dev/null –o StrictHostKeyChecking=no -i "/home/hduser/id_rsa" -l ${USERNAME} ${host}; – Eyüp Alemdar Mar 21 '14 at 18:51
0

The script somehow looks to root directory to send private key. It works after copied id_rsa and id_rsa.pub under /home/hduser/.ssh/ directory to /root/.ssh/ directory.

sudo cp -av /home/hduser/.ssh/id_rsa /root/.ssh/
sudo cp -av /home/hduser/.ssh/id_rsa.pub /root/.ssh/