SSH Key-Based Authentication on RHEL6

You've set up your new Red Hat Enterprise Linux 6 box and you can ssh in using passwords with no problem.

But now you want to stop using passwords and start using keys. So you install your keys:

scp .ssh/id_dsa.pub me@example.com:.ssh/authorized_keys

But the system keeps prompting you for a password! The keys don't seem to work at all.

That might be because SELinux is preventing it because the proper attributes are not on the authorized_keys file. Or possibly you have permissions wrong on your .ssh directory. The solution:

cd /home/me
chmod go-rwx .ssh
restorecon -R -v /path/to/.ssh

Restorecon will respond with

restorecon reset /home/me/.ssh context unconfined_u:object_r:user_home_t:s0->unconfined_u:object_r:ssh_home_t:s0
restorecon reset /home/me/.ssh/authorized_keys context unconfined_u:object_r:user_home_t:s0->unconfined_u:object_r:ssh_home_t:s0

It's always SELinux, isn't it?

Reference: RHEL6 SSH key

[ Submitted by John on Wed, 2011-02-09 11:28. | | ]

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options