SSHリバーストンネルは機能しますが、Davmailは機能しません。

SSHリバーストンネルは機能しますが、Davmailは機能しません。

私は誰かが私のVPSサーバー(サーバーと呼ばれる)を介してDavmail IMAPサーバーにアクセスすることを不可能にしようとしています(地域のブロックのために、しかし必ずしも関連しているわけではありません)。以下の図は、異なる当事者間の接続を説明しています。

接続図

このコマンドを使用して、Davmail(パブリックアクセスできない)からSSHサーバー(パブリックアクセス可能)にトンネルを設定します。

ssh -g -R \*:2143:localhost:1143 -N user@server

SSHサーバー自体でローカルホストとして使用すると、正しく接続され動作します。デバッグにはTelnetを使用しており、将来はIMAP(またはIMAPS)が必要です。

# telnet localhost 2143
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4REV1 AUTH=LOGIN MOVE SPECIAL-USE] IMAP4rev1 DavMail 5.5.1-trunk server ready
. LOGIN user pass
. OK Authenticated

ただし、ポートのSSHサーバーにリモートで接続すると接続されますが、(ほぼ)データは転送されません。

$ telnet server 2143
Trying 94.130.99.72...
Connected to server.
Escape character is '^]'.

そして接続が切断されました。ただし、この設定で使用すると、netcatが機能し、データが双方向に送信されます。 SSH クライアントは接続があることを示します。

debug3: receive packet: type 90
debug1: client_input_channel_open: ctype forwarded-tcpip rchan 4 win 2097152 max 32768
debug1: client_request_forwarded_tcpip: listen  port 2143, originator 195.113.180.82 port 16119
debug2: fd 6 setting O_NONBLOCK
debug2: fd 6 setting TCP_NODELAY
debug1: connect_next: host 192.168.10.161 ([192.168.10.161]:1143) in progress, fd=6
debug3: fd 6 is O_NONBLOCK
debug3: fd 6 is O_NONBLOCK
debug1: channel 2: new [195.113.180.82]
debug1: confirm forwarded-tcpip
debug3: channel 2: waiting for connection
debug1: channel 2: connected to 192.168.10.161 port 1143
debug3: send packet: type 91

Davmailには初期接続が表示されますが、実際には相手はデータを受信しません(私の知る限り)。

2024-03-03 17:06:44,338 DEBUG [davmail.imap.ImapServer] davmail  - Connection from /192.168.10.161 on port 1143
2024-03-03 17:06:44,338 INFO  [davmail.imap.ImapServer] davmail.connection  - CONNECT - 192.168.10.161:59732 
2024-03-03 17:06:44,382 DEBUG [ImapConnection-59732] davmail.exchange.ExchangeSession  - Test configuration status: 302
2024-03-03 17:06:44,383 DEBUG [ImapConnection-59732] davmail  - > * OK [CAPABILITY IMAP4REV1 AUTH=LOGIN MOVE SPECIAL-USE] IMAP4rev1 DavMail 5.5.1-trunk server ready

サーバーでファイアウォールが無効になっています。

# ufw status 
Status: inactive

GatewayPortが開いています。

# /etc/ssh/sshd_config
GatewayPorts yes
AllowTcpForwarding yes

どのようにさらにデバッグできますか?

ベストアンサー1

おすすめ記事