您可以同時使用 + 和 - 來編輯 sshd_config 選項嗎

您可以同時使用 + 和 - 來編輯 sshd_config 選項嗎

這裡的答案對我幫助很大。

然而,就我而言,我想禁用一些 MAC 並添加一些新的。有沒有辦法在不硬編碼選項的情況下做到這一點?

以下不起作用。

MACs +hmac-xxxx
MACs -hmac-gggg

在這種情況下,只有第一條語句才會起作用。有沒有一種方法可以在不進行硬編碼的情況下實現這一目標?

答案1

沒有辦法做到這一點。

ssh只會考慮第一個MACs(或Ciphers等)聲明並默默地忽略其餘聲明,儘管在它們格式錯誤時會抱怨。

你可以看一下原始碼。在readconf.c

        options->macs = NULL;
...
        case oMacs:
                arg = strdelim(&s);
                if (!arg || *arg == '\0')
                        fatal("%.200s line %d: Missing argument.", filename, lin
enum);
                if (*arg != '-' &&
                    !mac_valid(*arg == '+' || *arg == '^' ? arg + 1 : arg))
                        fatal("%.200s line %d: Bad SSH2 MAC spec '%s'.",
                            filename, linenum, arg ? arg : "<NONE>");
                if (*activep && options->macs == NULL)
                        options->macs = xstrdup(arg);
                break;

options->macs僅當尚未設定時才會設定(當它已設定時NULL

相關內容