Permissions denied to owner, although it is set to 666 in .ssh directory
I recently messed around with the .ssh directory. Made some permission changes, I think and now it won't let me access it anymore. I can access it as the root user (sudo -i) but not as user1
I get permission denied when listing or cding into .ssh even though it shows the files
ls: cannot access /home/user1/.ssh/amazon.pem: Permission denied
ls: cannot access /home/user1/.ssh/id_rsa: Permission denied
ls: cannot access /home/user1/.ssh/known_hosts: Permission denied
ls: cannot access /home/user1/.ssh/id_rsa.pub: Permission denied
total 0
-????????? ? ? ? ? ? amazon.pem
-????????? ? ? ? ? ? id_rsa
-????????? ? ? ? ? ? id_rsa.pub
-????????? ? ? ? ? ? known_hosts
Logging in as root and ls gives following results
# ls -l /home/user1/ -a |grep ssh
drw-rw-rw- 2 user1 user1 4096 Aug 27 15:45 .ssh
Even the files inside are .ssh are owned by user1:user1 and chm
-rw-rw-rw- 1 user1 user1 1692 Aug 27 15:45 amazon.pem
-rw-rw-rw- 1 user1 user1 1675 Aug 25 20:01 id_rsa
Steeldriver is right. On directory you need also x
access flag to be able to list files inside.
Fixing the directory using chmod 700 ~/.ssh
should help you to get into this (correct) state:
$ ls -ld ~/.ssh
drwx------. 2 user user 4096 Aug 26 10:37 /home/user/.ssh
Also you should fix your keys using chmod 600 ~/.ssh/id_rsa
and chmod 644 ~/.ssh/*.pub
to get this:
$ ls -l ~/.ssh/
-rw-------. 1 user user 1766 Mar 7 2014 id_rsa
-rw-r--r--. 1 user user 415 Mar 7 2014 id_rsa.pub