ssh login without giving a password RHEL5

Thank you to Mathias Kettner for his article at

My need was to pull a text stream from Server B into Server A. It was actually an osCommerce problem: I need a plain text input to UnForm, our form-making software. At the time our backend system gets ready to print a pick ticket for warehouse personnel, I need the backend system to call back to the osCommerce database and grab the packing slip information.

This is due to a limitation in our backend software – we can’t store the part numbers the way they need to be displayed to the customer. The backend software is not an SQL-based solution, so cramming extra fields into the backend is a painful process.

However, we don’t have to: the data exists … drat, on the webserver. That’s OK. With a little ssh program execution we can do it, have it come back to us as text, or simply send the data to the TCP port UnForm is listening on, and let it work its form-making magic.

To get ssh to execute a remote without passing passwords:

Here I’m assuming you already have usernames on both servers, and both servers are RHEL5. If not, please see Mathias’ directions, as he has a few extra tidbits you may need.

1. Logon on to the server that you will be executing the ssh commands from, let’s call that Server A. There, you’ll create your authentication key pairs:

ssh-keygen -t rsa

2. Append the Server A’s public key to Server B’s authorized keys. You’ll of course be prompted for your password – for the last time.

cat .ssh/ | ssh userB@serverB 'cat >> .ssh/authorized_keys'

3. Sign in to serverB, because you have to set the permissions correctly on the authorized_keys file:

ssh userB@serverB
(enter password)
userB@serverB> chmod 640 ./.ssh/authorized_keys

4. You should be good to go! Try a simple test (from serverA):

userA@serverA> ssh userB@serverB "pwd"