Home

Geeklog: What I Learnt Today / Adam

ssh using keys on CentOS (SE Linux) issues

> So you want to login to ssh without a password using a key file. You created the ~/.ssh folder uploaded your public key file to ~/.ssh/authorized_keys set the permissions 700 for .ssh and 600 for authorized_keys and it still doesn't work?
If your on SE Linux you may want to check what the security context is
 ls -laZ  ~/.ssh
will show you. I found mine was set wrong, if so, you can do something like
chcon -R --type=ssh_home_t  ~/.ssh

Before I got it working I found it quite frustrating, tailing /var/secure/log was giving me entries like can't access /home/user/.ssh/authorized_keys. Even when I set logging to debug via sshd_config which wasn't very illuminating
This doesn't seem to be mentioned in many places so mentioning here in case it helps anybody else. You can read more about security context/ security labels.

/ Adam