LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-18-2012, 06:35 PM   #1
joseph85750
LQ Newbie
 
Registered: Dec 2010
Location: Tucson, AZ
Distribution: CentOS, Slackware, PlopLinux, Linux Mint
Posts: 10

Rep: Reputation: 0
SSH to root@box fails when trying key auth


I thought I'd share this for anyone finding themselves struggling with this in the future, saving themselves a few hours.


My goal was to ssh to system A and land on system B, running CentOS 6.2, as root:

ie: ssh root@systemB:

However, I continued to be prompted for password. I verified several dozen times the permissions were correct on both systems, since I've done this countless times in the past without issue and am familiar with the permissions issues. However, I was still struggling mightily. After trying many combinations and permutations of sshd_config settings, I finally stumbled upon the answer: It was SELinux.
In previous versions of CentOS, one could run:

# setup

And in the Firewall section disable SELinux. However, I didn't see this in 6.2. However, there does exist a file:

/etc/selinux/config

Which by default contains a line:

SELINUX=enforcing

I changed this to:

SELINUX=disabled

And rebooted. ssh then worked using the key auth.

This is in no way a suggestion for people to disable SELinux! I'm simply pointing out the culprit which was giving me so much grief, and causing my connection to fail silently.

I checked the /var/log/audit/audit.log, and saw my IP show up a few times, but wasn't sure what the entries meant:

===
type=CRYPTO_KEY_USER msg=audit(1340053446.926:14781): user pid=1571 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=18:61:6e:22:57:9c:5c:4e:7f:69:12:8a:2b:24:24:39 direction=? spid=1571 suid=0 : exe="/usr/sbin/sshd" hostname=? addr=10.4.3.10 terminal=? res=success'
===

But the fact that 'sshd' was in there was a clue.

Odd thing, after finding this, I went back and set it back to:

SELINUX=enforcing

To see the error again, but now I'm still able to ssh in as originally desired.

If anyone has another solution to permit this connectivity without disabling SELinux, feel free to post. Perhaps the solution is to disable it once, reboot, re-enable it, and you're set!



Cheers!
 
Old 06-18-2012, 07:21 PM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
First, thanks for posting the work around! I cannot stress enough how many times I've actually found solutions to things because people post solutions :-)

A test I would do is that I would check the SELinux contexts on the known_hosts file...maybe when it gets created; the contexts are set incorrectly?

I'd be interesting to see the "ll -Z known_hosts" NOW compared to one that isn't working...

-C
 
Old 06-19-2012, 12:29 PM   #3
joseph85750
LQ Newbie
 
Registered: Dec 2010
Location: Tucson, AZ
Distribution: CentOS, Slackware, PlopLinux, Linux Mint
Posts: 10

Original Poster
Rep: Reputation: 0
I added another interface to the VM and can now duplicate the issue. When I enable SELinux, I can not ssh as root to the system; when I disable SELinux, I am able to ssh to the system. However, the original interface remains accessible no matter how I set SELinux now.

What specifically would you like me to check?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
open-ssh vs. commercial ssh (tru64), public-key auth not possible? cf050 Linux - Networking 8 03-28-2012 11:15 AM
SSH : public key auth ? mrbiomathe Linux - Newbie 2 01-12-2010 11:46 AM
SSH with key based auth fails when SSHing to itself (OpenSSH) gimpy530 Linux - General 6 01-11-2010 08:21 PM
ssh public key auth without root acces possible ? mrbiomathe Linux - Newbie 2 11-29-2009 02:11 PM
ssh key auth problem Ammad Linux - General 4 06-23-2009 01:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration