2
我有幾臺服務器使用以下sshd配置。AllowGroups和root @ IP
# Authentication:
PermitRootLogin no
AllowGroups ssh
PubkeyAuthentication yes
PasswordAuthentication no
這意味着組「ssh」中的每個用戶都可以登錄,但只能使用pubkey。不允許登錄root。
但是必須有一個root的例外:我的備份服務器與$ ip必須以root用戶身份登錄。
我想:
AllowUsers [email protected]$ip
AllowGroups ssh
不過的AllowUsers覆蓋AllowGroups聲明。因此,從$ IP只有root可以登錄。
Match User root, Address $ip
PermitRootLogin {yes|without-password}
AllowUsers root
和
Match Address $ip
PermitRootLogin {yes|without-password}
AllowUsers *
兩個被完全忽略。組「ssh」中的普通用戶仍然只能登錄。
這是一個簡單的情況,用戶登錄限於pubkey和root登錄限於pubkey和某些IP。怎麼解決?
在authorized_keys中,ip地址必須用引號括起:from =「192.168.1.20」ssh-rsa ... 這兩種解決方案都可以正常工作。我採用授權密鑰的第二種方式 - 也許更「標準的方式」。 非常感謝! – Chickenmarkus
AllowUsers在一場比賽似乎被禁止,並可能在重新啓動時崩潰ssh服務。 (不知道雖然,長篇小說...) – dfherr