
我想在/etc/ssh/sshd_config
Protocol 2
Ciphers aes256-ctr
PermitRootLogin no
X11Forwarding no
Match User joebob
X11Forwarding yes
AuthorizedKeysFile .ssh/authorized_keys
PermitEmptyPasswords no
RSAAuthentication no
RhostsRSAAuthentication no
IgnoreUserKnownHosts no
問題是
啟動 SSH 守護程式 /etc/ssh/sshd_config 第 40 行:
匹配區塊中不允許指令“IgnoreUserKnownHosts”
看起來在 Match 語句之後的第一個指令之後有多少指令被包含在符合中?
如果我把 Match 語句放在檔案的最後,它就會起作用sshd_config
。
我不想那樣做。
有沒有一種方法可以讓我在文件頂部附近放置這個匹配語句,就在我的 X11Forwarding no 語句之後?
我在文件頂部有我關心的所有相關 ssh 設置,我希望我的匹配用戶在 X11forwarding no 之後,所以我知道它正在發生。如果它放在文件的底部,我會忘記它。
我的目標是為除/etc/passwd
.
答案1
正如man sshd_config
和Match
部分中所提到的:
在關鍵字後面的行中只能使用關鍵字的子集
Match
。可用的關鍵字有AllowAgentForwarding、AllowTcpForwarding、橫幅、ChrootDirectory、ForceCommand、GatewayPorts、GSSAPIAuthentication、HostbasedAuthentication、KbdInteractiveAuthentication、KerberosAuthentication、KerberosUseKuserok、MaxAuthentication、KerberosAuthenticationPasscyberosUseKuserok、MaxAuthTries、Kuthizor uthentication、PermitEmptyPasswords、PermitOpen、PermitRootLogin、RequiredAuthentications1、RequiredAuthenticationsRSA Rhosts2、驗證、RSA身份驗證、X11DisplayOffset、 X11Forwarding 和 X11UseLocalHost
很好,正如您所看到的,IgnoreUserKnownHosts
不能在“匹配”部分中。如果有的話,請將其移至第一個匹配項,或將所有Match
部分(如果有,一個或多個)放在設定檔的末尾(建議);否則 Match 後的所有配置將覆蓋全域配置並joebob
僅適用於您的使用者 ( )。
因此建議將所有匹配移動到設定檔的末尾。
注意:每個Match
區塊都可以透過啟動另一個Match
區塊或設定檔結束來結束,或者如果您鍵入Match All
此後的每個後續配置,則將被視為全域配置。
答案2
要標記匹配區塊的結尾,您可以使用“全部匹配”
Protocol 2
Ciphers aes256-ctr
PermitRootLogin no
X11Forwarding no
Match User joebob
X11Forwarding yes
Match all
AuthorizedKeysFile .ssh/authorized_keys
PermitEmptyPasswords no
RSAAuthentication no
RhostsRSAAuthentication no
IgnoreUserKnownHosts no