2015-04-25 106 views
5

我忘記了我在我的一臺Web服務器上啓用了SELinux。所以當我用我的用戶帳戶和ssh密鑰登錄到主機時,我得到了拒絕權限的錯誤。SELinux使用RSA密鑰阻止ssh

[[email protected]:~] #ssh [email protected] 
Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 

嗯......所以我安慰了服務器,並能夠登錄。我尾審計日誌,這是我所看到的:

type=USER_LOGIN msg=audit(1429981690.809:394593): pid=17074 uid=0  auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023  msg='op=login acct="bluethundr" exe="/usr/sbin/sshd" hostname=? addr=47.18.111.100 terminal=ssh res=failed' 

在google搜索這個問題的答案我的意見,運行此命令:

[[email protected]:~] #restorecon -R -v /home/bluethundr/.ssh 
[[email protected]:~] # 

但是,當我去重新登錄,這樣做後,我得到了同樣的結果。權限被拒絕並且日誌中出現相同的錯誤。

我唯一能想到的其他事情是用戶的主目錄是從NFS共享掛載的。可能有一些SELinux咒語可用於允許SSH到NFS共享的主目錄?

或者我錯過了別的東西?

感謝, 添

回答

9

如果restorecon沒有工作,我一般儘量audit2why和/或audit2allow找到政策被侵犯的。這並不是說我應用了所產生的政策變更建議,只是爲了解決問題提供了非常好的信息。

6

賓果遊戲!

當我跑audit2why -w這是輸出我看到:

[[email protected]:~] #grep ssh /var/log/audit/audit.log | audit2why -w 
Was caused by: 
    The boolean use_nfs_home_dirs was set incorrectly. 
    Description: 
    Allow use to nfs home dirs 

    Allow access by executing: 
    # setsebool -P use_nfs_home_dirs 1 
    type=AVC msg=audit(1429983513.529:394784): avc: denied { read } for pid=19748 comm="sshd" name="authorized_keys" dev="0:40" ino=275968 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:nfs_t:s0 tclass=file 

因此,它看起來像我以爲這是有關NFS和你的建議,使用audit2why讓我破案的預感!

[[email protected]:~/creds] #ssh [email protected] 
Last login: Sat Apr 25 13:41:02 2015 from ool-2f126f64.dyn.optonline.net 
[[email protected] ~]$ 

Bam !!有用。謝謝你的幫助!

+0

當然!作爲一個形式問題,你應該把格式化的內容告訴你如何解決你的問題,針對答案的任何具體評論,然後「接受」有效的答案。繼續使用SELinux,這對安全系統非常重要! :) –