LINUX.ORG.RU

stunnel не проходит файрволл/DLP

 


0

1

Ситуация: есть домашний сервер с внешним IP, открыт порт sshd во внешний мир. Необходимо подключаться к нему из другой сети, закрытой файрволлом. В этой другой сети работает DPI, распознаётся и блокируется SSH трафик на любом порту и всё кроме HTTP/HTTPS. Для обхода этой проблемы поднял SSL туннель для SSH, установив stunnel на домашний сервер и на клиента (лэптоп). Туннель работает нормально, могу подключаться из инета, но только не из этой сети за файрволлом. При попытке подключиться происходит следующее:

клиент

$ ssh -v home
OpenSSH_8.1p1 Debian-5, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 84: Applying options for home
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to home [::1] port 12443.
debug1: connect to address ::1 port 12443: Connection refused
debug1: Connecting to home [127.0.0.1] port 12443.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type -1
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: identity file /home/user/.ssh/id_xmss type -1
debug1: identity file /home/user/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1p1 Debian-5
kex_exchange_identification: read: Connection reset by peer

Логи сервера server_name; ip клиента заменён на 11.22.33.44

Mar 24 02:40:29 server_name stunnel[8060]: LOG5[1]: Service [sshd] accepted connection from 11.22.33.44:1886
Mar 24 02:40:29 server_name stunnel[8060]: LOG3[1]: SSL_accept: Peer suddenly disconnected
Mar 24 02:40:29 server_name stunnel[8060]: LOG5[1]: Connection reset: 0 byte(s) sent to TLS, 0 byte(s) sent to socket

При этом ssl соединение с домом через s_client из сети за файрволлом устанавливается нормально и не рвётся:

$ openssl s_client -tls1_3 -connect home:443
CONNECTED(00000003)
Can't use SSL_get_servername
depth=0 C = RU, CN = server_name
verify error:num=18:self signed certificate
verify return:1
depth=0 C = RU, CN = server_name
verify return:1
---
Certificate chain
 0 s:C = RU, CN = server_name
   i:C = RU, CN = server_name
---
Server certificate
-----BEGIN CERTIFICATE-----
<snip>
-----END CERTIFICATE-----
subject=C = RU, CN = server_name

issuer=C = RU, CN = server_name

---
No client certificate CA names sent
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 1481 bytes and written 543 bytes
Verification error: self signed certificate
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 18 (self signed certificate)
---
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
    Protocol  : TLSv1.3
    Cipher    : TLS_AES_256_GCM_SHA384

<snip>
    Start Time: 1585169666
    Timeout   : 7200 (sec)
    Verify return code: 18 (self signed certificate)
    Extended master secret: no
    Max Early Data: 0
---
read R BLOCK
SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2

< далее ждёт ввода >

Вопрос, почему мне рвут SSH подключение? Я так понимаю это отрабатывает DLP / файрволл? Но откуда посредник знает, что у меня внутри SSL туннеля?

Конфиг stunnel на сервере:

cert = /etc/stunnel/stunnel.pem
sslVersion = TLSv1.3
options = NO_SSLv2
options = NO_SSLv3
pid = /run/stunnel.pid

[sshd]
accept = 12443
connect = 10022

Конфиг stunnel на клиенте:

client = yes
sslVersion = TLSv1.3

[sshd]
accept = 12443
connect = home:443

~/.ssh/config на клиенте:

Host home
     Hostname localhost
     Port 12443

Надо понять чем этот голый SSL отличается от HTTPS. Попробуйте сдампить момент установления соединения к Stunnel’у и к обычному HTTPS серверу из нормальной сети используя тулзу вроде Wireshark’а, и посмотрите чем они отличаются.

DawnCaster ★★
()

Вместо stunnel попробовать shadowsocks?

rupert ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.