Помер сервер в локалке (по причине SSD). Ubuntu 20.04.
Поменяли SSD, сисадмин (windows only, mouse edition) накатил 22.04, дальше моя работа. Ubuntu server девственно чист, сделал только апдейт до текущего и поставил мелочевку (mc, htop, nmap, это вот все).
Для связи с ним у меня два варианта: openvpn и проброс порта (DNAT). Все на одном роутере с одним внешним IP. На роутере не трогали ничего (потому что зачем).
Проблема: через vpn подключается, что по ключу, что по паролю. Через DNAT категорически не хочет. Соединение начинается и зависает на первых этапах. Через какое-то время отваливается по таймауту.
Запускаю у себя ssh username@LAN_IP — подключается.
Запускаю ssh -p NNNNN username@WAN_IP — подключение зависает и через 4-5 минут отваливается.
Застревает здесь:
$ ssh -vvv -p NNNNN username@WAN_IP
OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /home/onotole/.ssh/config
debug1: /home/onotole/.ssh/config line 43: Applying options for aquarius
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 213.234.4.141 [213.234.4.141] port 27022.
debug1: Connection established.
debug1: identity file /home/onotole/.ssh/id_rsa type 0
debug1: identity file /home/onotole/.ssh/id_rsa-cert type -1
debug1: identity file /home/onotole/.ssh/id_ecdsa type 2
debug1: identity file /home/onotole/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/onotole/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/onotole/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/onotole/.ssh/id_ed25519 type -1
debug1: identity file /home/onotole/.ssh/id_ed25519-cert type -1
debug1: identity file /home/onotole/.ssh/id_ed25519_sk type -1
debug1: identity file /home/onotole/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/onotole/.ssh/id_xmss type -1
debug1: identity file /home/onotole/.ssh/id_xmss-cert type -1
debug1: identity file /home/onotole/.ssh/id_dsa type -1
debug1: identity file /home/onotole/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
через 5-6 минут добавляется:
kex_exchange_identification: read: Connection reset by peer
Connection reset by 213.234.4.141 port 27022
В sshd_config указал
LogLevel DEBUG3
Смотрю лог на сервере:
# tail -f /var/log/auth.log
(в syslog полная тишина)
Jun 2 21:03:03 web sshd[18058]: debug3: fd 5 is not O_NONBLOCK
Jun 2 21:03:03 web sshd[18058]: debug1: Forked child 18351.
Jun 2 21:03:03 web sshd[18058]: debug3: send_rexec_state: entering fd = 8 config len 3270
Jun 2 21:03:03 web sshd[18058]: debug3: ssh_msg_send: type 0
Jun 2 21:03:03 web sshd[18058]: debug3: send_rexec_state: done
Jun 2 21:03:03 web sshd[18351]: debug3: oom_adjust_restore
Jun 2 21:03:03 web sshd[18351]: debug1: Set /proc/self/oom_score_adj to 0
Jun 2 21:03:03 web sshd[18351]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
Jun 2 21:03:03 web sshd[18351]: debug1: inetd sockets after dupping: 4, 4
Jun 2 21:03:03 web sshd[18351]: Connection from 176.59.46.171 port 45044 on 172.23.30.32 port 22 rdomain ""
Jun 2 21:03:03 web sshd[18351]: debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
Jun 2 21:03:03 web sshd[18351]: debug1: Remote protocol version 2.0, remote software version OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
Jun 2 21:03:03 web sshd[18351]: debug1: compat_banner: match: OpenSSH_8.9p1 Ubuntu-3ubuntu0.1 pat OpenSSH* compat 0x04000000
Jun 2 21:03:03 web sshd[18351]: debug2: fd 4 setting O_NONBLOCK
Jun 2 21:03:03 web sshd[18351]: debug3: ssh_sandbox_init: preparing seccomp filter sandbox
Jun 2 21:03:03 web sshd[18351]: debug2: Network child is on pid 18352
Jun 2 21:03:03 web sshd[18351]: debug3: preauth child monitor started
Jun 2 21:03:03 web sshd[18351]: debug3: privsep user:group 106:65534 [preauth]
Jun 2 21:03:03 web sshd[18351]: debug1: permanently_set_uid: 106/65534 [preauth]
Jun 2 21:03:03 web sshd[18351]: debug3: ssh_sandbox_child: setting PR_SET_NO_NEW_PRIVS [preauth]
Jun 2 21:03:03 web sshd[18351]: debug3: ssh_sandbox_child: attaching seccomp filter program [preauth]
Jun 2 21:03:03 web sshd[18351]: debug3: append_hostkey_type: ssh-rsa key not permitted by HostkeyAlgorithms [preauth]
Jun 2 21:03:03 web sshd[18351]: debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
Jun 2 21:03:03 web sshd[18351]: debug3: send packet: type 20 [preauth]
Jun 2 21:03:03 web sshd[18351]: debug1: SSH2_MSG_KEXINIT sent [preauth]
Через 2-3 минуты (намного раньше, чем в логе клиента) добавляется:
Jun 2 21:05:03 web sshd[18351]: fatal: Timeout before authentication for 176.59.46.171 port 45044
Пробовал отключить аутентификацию по ключу:
PubkeyAuthentication no
До запроса пароля процесс не доходит, зависает там же, в логе всё те же слова про hostkey.
# tail -f /var/log/auth.log
Jun 2 21:16:46 web sshd[18374]: debug3: fd 5 is not O_NONBLOCK
Jun 2 21:16:46 web sshd[18374]: debug1: Forked child 18381.
Jun 2 21:16:46 web sshd[18374]: debug3: send_rexec_state: entering fd = 8 config len 3269
Jun 2 21:16:46 web sshd[18374]: debug3: ssh_msg_send: type 0
Jun 2 21:16:46 web sshd[18374]: debug3: send_rexec_state: done
Jun 2 21:16:46 web sshd[18381]: debug3: oom_adjust_restore
Jun 2 21:16:46 web sshd[18381]: debug1: Set /proc/self/oom_score_adj to 0
Jun 2 21:16:46 web sshd[18381]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
Jun 2 21:16:46 web sshd[18381]: debug1: inetd sockets after dupping: 4, 4
Jun 2 21:16:46 web sshd[18381]: Connection from 176.59.46.171 port 26002 on 172.23.30.32 port 22 rdomain ""
Jun 2 21:16:46 web sshd[18381]: debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
Jun 2 21:16:46 web sshd[18381]: debug1: Remote protocol version 2.0, remote software version OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
Jun 2 21:16:46 web sshd[18381]: debug1: compat_banner: match: OpenSSH_8.9p1 Ubuntu-3ubuntu0.1 pat OpenSSH* compat 0x04000000
Jun 2 21:16:46 web sshd[18381]: debug2: fd 4 setting O_NONBLOCK
Jun 2 21:16:46 web sshd[18381]: debug3: ssh_sandbox_init: preparing seccomp filter sandbox
Jun 2 21:16:46 web sshd[18381]: debug2: Network child is on pid 18382
Jun 2 21:16:46 web sshd[18381]: debug3: preauth child monitor started
Jun 2 21:16:46 web sshd[18381]: debug3: privsep user:group 106:65534 [preauth]
Jun 2 21:16:46 web sshd[18381]: debug1: permanently_set_uid: 106/65534 [preauth]
Jun 2 21:16:46 web sshd[18381]: debug3: ssh_sandbox_child: setting PR_SET_NO_NEW_PRIVS [preauth]
Jun 2 21:16:46 web sshd[18381]: debug3: ssh_sandbox_child: attaching seccomp filter program [preauth]
Jun 2 21:16:46 web sshd[18381]: debug3: append_hostkey_type: ssh-rsa key not permitted by HostkeyAlgorithms [preauth]
Jun 2 21:16:46 web sshd[18381]: debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
Jun 2 21:16:46 web sshd[18381]: debug3: send packet: type 20 [preauth]
Jun 2 21:16:46 web sshd[18381]: debug1: SSH2_MSG_KEXINIT sent [preauth]
ИТОГО.
Все вроде правильно, но через портмаппинг не подключается, а через openvpn подключается.
До этого все работало без проблем, пока была жив сервер 20.04.