Today when I try to SSH into my server, I get a permission denied message (same for sftp). It used to work well before, I didn't change any server settings, except I was trying to modify a few folders chown permission.

Root user can ssh/sftp without problem.

(For root user, there is no .ssh/authorized_keys file, only a .ssh/known_hosts file. For normal user home folder does not have a .ssh folder).

2 Answers 2


you said you have root access. ssh to the box as root and see what exactly is causing it. check the master log file /var/log/messages.

keep this command tail -f /var/log/messages running in a terminal and ssh to the server as a normal user. Look at the entries in log file.

  • Accepted password for USER from port 51550 ssh2 pam_unix(sshd:session): session opened for user USER by (uid=0). that's the log file message. but in the ssh terminal, the error message is "-bash: /dev/null: Permission denied" please advice if there is anything i can try. thx
    – Angel Wong
    Sep 1, 2012 at 10:24
  • check your .profile, .bashrc, and/or .bash_profile scripts. that sounds like there might be a line like exec /dev/null (possibly intended as something like exec 2>/dev/null). Also, as root, check the perms on /dev/null, it should be owned by root:root, perms 666 (crw-rw-rw).
    – cas
    Sep 1, 2012 at 14:16
  • actually, ignore what i said about your login scripts, it sounds like it's a permissions problem with /dev/null. make sure perms are 666. lmgtfy.com/?q=%22bash%3A+%2Fdev%2Fnull%3A+Permission+denied%22
    – cas
    Sep 1, 2012 at 15:24
  • thx Craig. works like a charm
    – Angel Wong
    Sep 2, 2012 at 15:55

It sounds like you might have changed the permissions of your ~/.ssh directory and/or your ~/.ssh/authorized_keys file. Or possibly made your home dir group or world writable.

~/.ssh should be 700 (drwx------) and ~/.ssh/authorized_keys should be 600 (-rw-------).

Your private key file(s) in ~/.ssh (id_rsa, id_dsa, etc) should also be 600. The perms on the public key files (id_rsa.pub, id_dsa.pub, etc) are less strict - they can be world-readable.

All these files and directories should be owned by your user.

If your home directory is world-writable and StrictModes is set in sshd_config (default is "yes"), then sshd will not trust anything underneath your home directory (including ~/.ssh and everything in it) because a world-writable hoome dir means any user on the system could have created or modified the files.

I'm not sure how sshd on Centos handles group-writable home dirs, but the same may apply if your home dir is group-writable - any user in the group may have created/altered the ~/.ssh files. (IIRC Debian's sshd is configured to allow group-writable home dirs because Debian's adduser traditionally creates a group for each user which only the user is a member of)

  • as said, there is no authorized_keys file in both root and normal user account. also, .ssh folder does not exist in user home directly. .ssh folder only in root directly, and permission is 600. please advice if there is any other thing i can try. thx a lot
    – Angel Wong
    Sep 1, 2012 at 10:26
  • from your answer to fayadlami, it sounds like you're logging in successfully. i'll comment more under f's answer.
    – cas
    Sep 1, 2012 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .