Passwordless SSH behaving oddly
I have two red hat VMs that I need to be able to use passwordless SSH between the two.
Here's the scenario:
On VM1 and VM2 I have user bob with home directory /aim/bob_home (I didn't choose the location). On VM1 as user bob I run ssh-keygen -t rsa which generates the id_rsa/id_rsa.pub files in the .ssh/ dir.
Then I run ssh-copy-id -i bob_AT_<ip of VM2> - I am prompted for bob's password on VM2 and enter it. After to command completes I check the authorized_keys file on VM2 and ensure that the key is correct. I've ensured that the permissions on the home dir, .ssh dir, and id_rsa/id_rsa.pub are all correct.
At this point I should be able to run ssh bob_AT_<ip of vm2> and immediately get a shell for VM2 but I'm still prompted for a password.
I've tried 'ssh-add' and 'service sshd restart (as root)' on both machines and neither helps. The firewalls on both machines are disabled. Each machine can ping the other...
Here's where it gets odd. If I shut down ssh on VM2 and restart it on a different port (/usr/sbin/sshd -p 1234) and clear the iptables (/etc/init.d/iptables save/stop) I can get in without a password (ssh -p 1234 bob_AT_<ip of vm2>.
Then on VM2 I can shut down ssh and start it back up on it's regular port (22) and I can still passwordless ssh into VM2 (ssh bob_AT_<ip of VM 2>.
This works until I reboot the VM at which point I have to do the ssh on a different port series of commands. What's going on here?
tl;dr passwordless ssh doesn't work until I change the ssh port and clear iptables, ssh in, then change the port back. After I reboot the machine I have to change the port again...