I was working on getting SSH setup again between my dedicated server and my home server so that I could once again do backups and copy them to a remote host. I had SSH’d into both boxes from the other and created my DSA key, copied the public key to the other server and tested it out. I could SSH passwordless from my home server to my dedicated server, but not from my dedicated server to my home server. It had me baffled for about a week.
Finally today I was in #wordpress and roddie helped me out. After about 6 hours of back and forth while I was at work, during my free “seconds” between issues today, then finally when I got home, we managed to figure out what the problem was.
We killed SSH then restarted it via /usr/sbin/sshd -4 -ddd -D which forced it to start but not fork into a daemon. After playing around and not seeing all of the error messages, I got smart and did a /usr/sbin/sshd -4 -ddd -D 2> /ssh_debug.txt to send all the messages to a file so I could read the full list of debugging errors. I pasted it and we both noticed
debug1: trying public key file /home/ryan/.ssh/authorized_keys
Authentication refused: bad ownership or modes for file /home/ryan/.ssh/authorized_keys
I checked the permissions on the file. Yes, it was owned by the right user, chmod’d the authorized_keys file to 600 and it was still prompting me for a password. All of the sudden roddie asked me to check the permissions on the ~/.ssh directory and told me it should have been 755. Nope, they were set to 775. Fixed that up and tested again and this time it finally worked.
Then I remembered back to when I was setting it up and that for some strange reason the ~/.ssh folder was not automatically created so I just did it myself. Not thinking, my umask was set to 022 instead of 002 and the permissions were originally set wrong. Sometimes I wonder why I get myself into these things. But now I know and now I can finally get back to modifying my backup script so I can get nightly snapshots of my server.