首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >匹配sshd_config中的用户位置

匹配sshd_config中的用户位置
EN

Unix & Linux用户
提问于 2020-03-19 16:41:47
回答 2查看 2.9K关注 0票数 1

我想在/etc/ssh/sshd_config上做这个

代码语言:javascript
复制
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

问题是

代码语言:javascript
复制
Starting SSH daemon/etc/ssh/sshd_config line 40:

Directive 'IgnoreUserKnownHosts' is not allowed within a Match block

但是,在match语句之后的第一个指令之后,似乎包含了许多指令,作为匹配的一部分?

如果我把它放在sshd_condig文件的末尾,那么我的Match语句就能工作。

我不想那样做。

有没有办法让这个match语句靠近文件的顶部,就在我的X11Forwarding no语句之后?

我有我关心的所有相关的ssh设置在文件的顶部,我希望我的匹配用户就在X11forwarding no之后,所以我知道它正在发生。如果把它放在文件的底部,我就忘了它。

我的目标是为每个人禁用X11Forwarding,但/etc/passwd中定义的本地用户帐户除外。

EN

回答 2

Unix & Linux用户

回答已采纳

发布于 2020-03-19 16:55:34

man sshd_configMatch部分所述:

Match关键字后面的行上只能使用关键字的子集。可用关键字有: AllowAgentForwarding、AllowTcpForwarding、Banner、ChrootDirectory、ForceCommand、GatewayPorts、GSSAPIAuthentication、HostbasedAuthentication、KbdInteractiveAuthentication、KerberosAuthentication、KerberosUseKuserok、MaxAuthTries、MaxSessions、PubkeyAuthentication、AuthorizedKeysCommand、AuthorizedKeysCommandRunAs、PasswordAuthentication、PermitEmptyPasswords、PermitOpen、PermitRootLogin、en19#、和

很好,正如您所看到的,IgnoreUserKnownHosts不能在Match部分。如果您有或将所有Match部件(如果有的话,一个或多个)移到第一个匹配的上面,或者将所有的配置部件(如果有的话,一个或多个)移到配置文件的末尾(这是建议的);否则,所有匹配后的配置都将覆盖全局配置,并仅应用于该用户(joebob)。

因此建议将所有的匹配移到配置文件的末尾。

票数 1
EN

Unix & Linux用户

发布于 2021-05-17 20:11:21

若要标记匹配块的结束,可以使用“匹配所有”。

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/573792

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档