nftables на сервере блокирует вход по SSH (с более надежным ключом SSH)

Попробуйте объединить все это в одну гигантскую normal!команду:

:argdo norm! /ABCD\_[^a-zA-Z]<C-v><CR>qaq:g//norm! "A3Y<C-v><CR>ggVG"ap

Использование <C-v><cr>позволяет ввести буквальный возврат каретки. Это устраняет вашу проблему, но в вашем подходе все еще есть много вещей, которые не идеальны.

Например:

  • Нет необходимости что-то искать, а потом использовать :g//. Вместо этого просто используйте :g/ABCD\_[^a-zA-Z].

  • Вы можете использовать \_Aвместо\_[^a-zA-Z]

  • Нет необходимости заставлять глобальную команду выполнять обычную команду. Вместо этого выполните команду ex, и вам не нужно будет очищать регистр «a». Так и :g/ABCD\_A/3ay.

Собрав все это воедино, я бы рекомендовал

:argdo norm! :g/ABCD\_A/3ya<C-v><CR>ggVG"ap
0
24.08.2019, 04:19
1 ответ

SSH-соединение при использовании SSH-ключей большого размера -и при использовании брандмауэра nftables, очевидно, что SSH занимает немного больше времени для обработки и прохождения через различные компоненты, поэтому весь процесс аутентификации SSH требует больше времени, но мое указанное/настроенное время -настроек было недостаточно.

Без включения/включения nftables подключение по SSH от старого компьютера с macOS к серверу -3 обычно занимает примерно менее ~10 секунд. (Таким образом, мои начальные настройки времени с 20 или 18 секундами были достаточными, когда nftables не был загружен/запущен ).
Но когда nftables был загружен и включен/включен на SSH-сервере, тогда старому компьютеру с macOS (и сети nftables на стороне сервера -, действиям по фильтрации пакетов и т. д. всем вместе )потребовалось еще 15–20 секунд для завершения SSH. процесс аутентификации.

Решение ::Увеличить значение тайм-аута/интервала/времени активности(для ServerAliveInterval + ServerAliveCountMax и ClientAliveInterval + ClientAliveCountMax), ИЛИ , Удалить настройки времени ожидания(Для использования значений по умолчанию ),как показано ниже:

Удалены/отключены (или превращены в комментарии )эти строки в файле~/.ssh/config в macOS SSH -Клиентский компьютер:

# ConnectTimeout 30
# ConnectTimeout 15
# ConnectTimeout 18
# ConnectionAttempts 1

Изменены следующие настройки/строки в файле ~/.ssh/config:

Из:
ServerAliveInterval 20
ServerAliveCountMax 1
вышеуказанные настройки поддерживали соединение только в течение 20 x 1 = 20 секунд

К:

ServerAliveInterval 18  
ServerAliveCountMax 2

указанные выше настройки поддерживают соединение в течение 18 x 2 = 36 секунд

И изменены ниже настройки/строки в файле /etc/ssh/sshd _config в Debian -10 Серверный компьютер:

Из:
ClientAliveInterval 30
ClientAliveCountMax 1
вышеуказанные настройки поддерживали соединение только в течение 30 x 1 = 30 секунд

К:

ClientAliveInterval 18
ClientAliveCountMax 2

указанные выше настройки поддерживают соединение в течение 18 x 2 = 36 секунд

Документированная информация из (macOS):man ssh _config

ServerAliveCountMax
    Sets the number of server alive messages (see below) which may be
    sent without ssh(1) receiving any messages back from the server.
    If this threshold is reached while server alive messages are being
    sent, ssh will disconnect from the server, terminating the session.
    It is important to note that the use of server alive messages is
    very different from TCPKeepAlive (below).  The server alive messages
    are sent through the encrypted channel and therefore will not be
    spoofable.  The TCP keepalive option enabled by TCPKeepAlive is
    spoofable.  The server alive mechanism is valuable when the client
    or server depend on knowing when a connection has become inactive.

    The default value is 3.  If, for example, ServerAliveInterval (see
    below) is set to 15 and ServerAliveCountMax is left at the default,
    if the server becomes unresponsive, ssh will disconnect after
    approximately 45 seconds.

ServerAliveInterval
    Sets a timeout interval in seconds after which if no data has been
    received from the server, ssh(1) will send a message through the
    encrypted channel to request a response from the server.
    The default is 0, indicating that these messages will not be sent
    to the server.

ConnectionAttempts
    Specifies the number of tries (one per second) to make before exiting.
    The argument must be an integer.  This may be useful in scripts if
    the connection sometimes fails.  The default is 1.

ConnectTimeout
    Specifies the timeout (in seconds) used when connecting to the SSH
    server, instead of using the default system TCP timeout.  This value
    is used only when the target is down or really unreachable, not
    when it refuses the connection.

Документированная информация из (Debian Server -3):man sshd _config

ClientAliveCountMax
    Sets the number of client alive messages which may be sent without
    sshd(8) receiving any messages back from the client.  If this threshold
    is reached while client alive messages are being sent, sshd will
    disconnect the client, terminating the session.  It is important to
    note that the use of client alive messages is very different from
    TCPKeepAlive.  The client alive messages are sent through the
    encrypted channel and therefore will not be spoofable.  The TCP
    keepalive option enabled by TCPKeepAlive is spoofable.
    The client alive mechanism is valuable when the client or server
    depend on knowing when a connection has become inactive.

    The default value is 3.  If ClientAliveInterval is set to 15, and
    ClientAliveCountMax is left at the default, unresponsive SSH clients
    will be disconnected after approximately 45 seconds.

ClientAliveInterval
    Sets a timeout interval in seconds after which if no data has been
    received from the client, sshd(8) will send a message through the
    encrypted channel to request a response from the client.  The default
    is 0, indicating that these messages will not be sent to the client.

С учетом исправлений, упомянутых в нескольких абзацах выше, теперь любые клиентские компьютеры SSH могут подключаться к SSH-серверу, даже если nftables включен/включен. Хотя в настоящее время для подключения через SSH требуется от ~от 35 до 45 секунд, если брандмауэр nftables включен/включен.

Мне придется дополнительно настроить эти параметры/значения времени, так как я хочу повторно -создать еще один туннель SSH, как только или в течение 20–40 секунд просроченного/отключенного/устаревшего соединения SSH (между клиентами Debian ssh -и серверами Debian ssh -).

0
28.01.2020, 03:21

Теги

Похожие вопросы