11

我正在设置一个新的 Linux 服务器,并且正在编辑 sshd_config。我将使用协议版本 2(无论如何都是默认的):

Protocol 2

但是在默认的配置文件中,我也找到了这两行:

KeyRegenerationInterval 3600
ServerKeyBits 768

手册页 sshd_config(5) 说 KeyRegenerationInterval:

在协议版本 1 中,临时服务器密钥会在这么多秒后自动重新生成(如果已使用)。再生的目的是防止通过以后闯入机器并窃取密钥来解密捕获的会话。密钥永远不会存储在任何地方。如果值为 0,则永远不会重新生成密钥。默认值为 3600(秒)。

所以我知道这个参数在 SSH1 中的作用。但我不使用SSH1。我使用默认版本 SSH2,但手册页没有提供有关协议版本 2 中的效果的信息。KeyRegenerationInterval在协议版本 2 中有KeyRegenerationInterval任何影响吗?那么ServerKeyBits呢?

如果我在设置时将此设置保留在配置文件中会发生什么Protocol 2?当我删除这两行时会发生什么?

我猜如果协议版本设置为 2,这两个参数将被忽略。但这只是猜测。从我读到现在我不能确定。你知道(不是猜测)在 SSH2 中有KeyRegenerationInterval什么效果吗?ServerKeyBits

4

3 回答 3

12

我相信你已经知道了。我只是不想让这个问题得不到回答。这些选项(KeyRegenerationInterval 和 ServerKeyBits)会影响为 SSH 协议 1 生成的服务器密钥。如果您要求连接遵守协议 2,则不必担心这一点。

于 2015-02-06T10:15:49.867 回答
3

TL;DR:不,这些选项在 SSH-2 中无效(自 2016 年起删除了 SSH-1 支持)。

如果不确定,源代码是最好的文档。

如果我们在整个 OpenSSH 源代码中搜索ServerKeyBits和,我们只会在以下位置找到KeyRegenerationIntervalservconf.c

        { "serverkeybits", sDeprecated, SSHCFG_GLOBAL },
        . . .
        { "keyregenerationinterval", sDeprecated, SSHCFG_GLOBAL },
        . . .

    case sDeprecated:
    case sIgnore:
    case sUnsupported:
        do_log2(opcode == sIgnore ?
            SYSLOG_LEVEL_DEBUG2 : SYSLOG_LEVEL_INFO,
            "%s line %d: %s option %s", filename, linenum,
            opcode == sUnsupported ? "Unsupported" : "Deprecated", arg);
        while (arg)
            arg = strdelim(&cp);
        break;

换句话说,这两个选项都只是打印一个弃用警告并且没有任何效果

然后使用责备功能,我们发现选项在2016 年 8 月 23 日的提交c38ea6348 (OpenSSH 7.4p1) 中被删除:

Remove more SSH1 server code: * Drop sshd's -k option. *
Retire configuration keywords that only apply to protocol 1, as well as   the
"protocol" keyword. * Remove some related vestiges of protocol 1 support.

在此之前,它们仅用于 SSH-1。例如KeyRegenerationInterval

    { "keyregenerationinterval", sKeyRegenerationTime, SSHCFG_GLOBAL },
    . . .

    case sKeyRegenerationTime:
        intptr = &options->key_regeneration_time;
        goto parse_time;

sshd.c/L1442中使用:

            if ((options.protocol & SSH_PROTO_1) &&
                key_used == 0) {
                /* Schedule server key regeneration alarm. */
                signal(SIGALRM, key_regeneration_alarm);
                alarm(options.key_regeneration_time);
                key_used = 1;
            }

注意:对于 SSH-2,有一个更强大的RekeyLimit.

于 2020-11-02T20:36:56.357 回答
1

对于原型 2,有这样的:

密钥限制

Specifies the maximum amount of data that may be transmitted
before the session key is renegotiated, optionally followed a
maximum amount of time that may pass before the session key is
renegotiated. The first argument is specified in bytes and
may have a suffix of 'K', 'M', or 'G' to indicate Kilobytes,
Megabytes, or Gigabytes, respectively.
The default is between '1G' and '4G', depending on the cipher.
The optional second value is specified in seconds and may use
any of the units documented in the TIME FORMATS section.
The default value for RekeyLimit is default none, which
means that rekeying is performed after the cipher's default
amount of data has been sent or received and no time based
rekeying is done.

来源 :

https://www.freebsd.org/cgi/man.cgi?sshd_config(5)
于 2020-07-01T12:11:14.940 回答