掃二維碼與項目經理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯網交流
一般為了方便運維管理都會配置ssh免密登錄,ssh免密登錄實現也很方便。今天遇到一個完成了配置了卻不能生效的問題。
遇到這個問題一般有以下幾點:
檢查AuthorizedKeysFile配置是否啟用authorized_keys
root@pts/1 $ cat /etc/ssh/sshd_config |egrep AuthorizedKeysFile
AuthorizedKeysFile .ssh/authorized_keys
沒有問題,繼續(xù)檢查.ssh (700) 和 authorized_keys(644) 權限
root@pts/1 $ getfacl /root/.ssh/
getfacl: Removing leading '/' from absolute path names
# file: root/.ssh/
# owner: root
# group: root
user::rwx
group::---
other::---
root@pts/1 $ getfacl /root/.ssh/authorized_keys
getfacl: Removing leading '/' from absolute path names
# file: root/.ssh/authorized_keys
# owner: root
# group: root
user::rw-
group::---
other::---
authorized_keys 權限不對,修改一下chmod 644 authorized_keys
再次嘗試結果發(fā)現還是不行。但是該設置的權限都設置了。既然.ssh目錄和其下文件的權限都OK了,那就檢查下其父目錄的權限,也就是這里的/root的權限
root@pts/1 $ getfacl /root/
getfacl: Removing leading '/' from absolute path names
# file: root/
# owner: ftpuser
# group: ftpuser
user::r-x
group::r-x
other::---
發(fā)現這里/root 的屬主都發(fā)生了變化。為了不影響別的業(yè)務情況,保留這里的ftpuser權限,利用setfacl添加特殊ACL權限
root@pts/1 $ chown -R root:root /root/
root@pts/1 $ setfacl -m u:ftpuser:rwx /root/
root@pts/1 $ getfacl /root/
getfacl: Removing leading '/' from absolute path names
# file: root/
# owner: root
# group: root
user::rwx
user:ftpuser:rwx #effective:r-x
group::r-x
mask::r-x
other::r-x
權限問題
開啟文件AuthorizedKeysFile .ssh/authorized_keys

我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯網交流