是否可以在 sshd_config 中打断长行?

Ale*_*yak 19 ssh configuration

具体AllowUsers参数:

例如转换这个

AllowUsers user1 user2 user3 user4
Run Code Online (Sandbox Code Playgroud)

对此

AllowUsers
    user1
    user2
    user3
    user4
Run Code Online (Sandbox Code Playgroud)

Gil*_*il' 13

不,但在这种情况下它没有用。可以有多个AcceptEnvAllowGroupsAllowUsersDenyGroupsDenyUsersHostKeyPermitOpenPortSubsystem线,并且每条线将一个或多个(或有时零)元素到列表中。

尽管如此,如果您不能轻松地将AllowUsers指令放在一行中,我建议创建一个ssh_allowed组并使用AllowGroups ssh_allowedin sshd_config

  • 在制作`KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-25 `更具可读性 (3认同)
  • 您可以同时使用“AllowGroups”和“AllowUsers”,但如果您使用 OpenSSH 守护程序,则仅允许允许的用户登录,前提是他们也在允许的组中。换句话说,它是“和”(交集),而不是“或”(联合)。 (2认同)

Mic*_*zek 12

简而言之,它看起来像没有

OpenSSHservconf.c将文件转储到缓冲区中而不检查这些事情(它似乎只是寻找#标记注释):

while (fgets(line, sizeof(line), f)) {
    if ((cp = strchr(line, '#')) != NULL)
        memcpy(cp, "\n", 2);
    cp = line + strspn(line, " \t\r");

    buffer_append(conf, cp, strlen(cp));
}
Run Code Online (Sandbox Code Playgroud)

解析配置的函数然后在换行符上拆分缓冲区并处理每一行:

while ((cp = strsep(&cbuf, "\n")) != NULL) {
    if (process_server_config_line(options, cp, filename,
        linenum++, &active, user, host, address) != 0)
    bad_options++;
}
Run Code Online (Sandbox Code Playgroud)