Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a headless server with (until recently) working SSH and public key auth. I deactivated passwords and had a problem resembling the one in this thread, ie. upon SSH-ing into my server I get: Permission denied (publickey).

Ratnakar Pawar helpfully suggested:

 $chmod go-w ~/
 $chmod 700 ~/.ssh
 $chmod 600 ~/.ssh/authorized_keys

Which solved both priyaudupi's issue and - for a time - mine. However now this issue seems to automatically reset on a 24-48 hour basis, I have changed the authorisation correctly twice (plugging in my keyboard and very carefully blind typing commands. This gives me normal passwordless, public auth ssh from the single authorised computer... then fails again within 48 hours.

What might be causing this, I can't think of anything that would be able to automatically change permissions on my folders either... any suggestions?

Update 2nd May 2014

I have checkedcrontab -l for both the root and user, I have nothing on my user. The only cron task on root is one that updates my DNS server. It does so more regularly than the problem re-occurs and does not use chmod or chown...

share|improve this question
1  
Do you have any cronjobs running that might change the permissions? –  Louis Matthijssen Apr 27 at 11:33
    
Not as far as I know... the only Cron job I made after a fresh install was one that prods my DNS update to work... –  Huw Apr 27 at 11:51
    
Anyone have any suggestions on how you would begin to debug this? –  Huw Apr 28 at 17:59
    
I would run grep sshd /var/log/auth.log | tail and see if there are any error messages about a public key not being accepted. (Replace tail with less to get scrollable full output if tail doesn't reveal anything) –  saiarcot895 May 2 at 12:12
    
Thanks for the help you two. Solved, posted below –  Huw May 2 at 13:20

1 Answer 1

up vote 0 down vote accepted

This is now resolved.

It was not an issue with SSH, nor the config tutorials but rather an incorrect diagnosis of the problem.

It turns out the SSH access issue did occur on a 24-48 hour basis, but looking back, this was only because 1) someone unplugged it, 2) we had a power-cut 3) I rebooted after a big update.

The common denominator being that I restarted the server, meaning when I was not logged in, my home directory remained encrypted and my authorized keys were not registering. Doh... what a noob.

So it was a red herring. The solution (moving the auth keys file out of the encrypted home directory) can be found in the wonderful Ubuntu ssh guide - troubleshooting section

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.