I posted a question at Ask Different about SSH tunneling of VNC and SMB on MacOS because I thought it was specific for Mac, but it doesn't seem so. In short, I can SSH from my machine A to machine B (both are Macs), both when A is on the same LAN as B as well as when A is outside the LAN. I can also connect via VNC and SMB from A to B when I am on the same LAN. However, when I try to open an SSH-tunnel from A to B to tunnel VNC or SMB when I am not on the LAN the connection fails.
I have verified that I use the right command % ssh -L 1445:127.0.0.1:445 -L 15900:127.0.0.1:5900 -p 2216 -v myhost and URL vnc://127.0.0.1:15900. I have also enabled verbose SSH-logging (this is when I connect SSH):
debug1: Local connections to LOCALHOST:1445 forwarded to remote address 127.0.0.1:445
debug1: Local forwarding listening on ::1 port 1445.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 1445.
debug1: channel 1: new [port listener]
debug1: Local connections to LOCALHOST:15900 forwarded to remote address 127.0.0.1:5900
debug1: Local forwarding listening on ::1 port 15900.
debug1: channel 2: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 15900.
debug1: channel 3: new [port listener]
debug1: channel 4: new [client-session]
This is from a failed VNC-connection:
debug1: Connection to port 15900 forwarding to 127.0.0.1 port 5900 requested.
debug1: channel 5: new [direct-tcpip]
debug1: Connection to port 15900 forwarding to 127.0.0.1 port 5900 requested.
debug1: channel 6: new [direct-tcpip]
debug1: channel 5: free: direct-tcpip: listening port 15900 for 127.0.0.1 port 5900, connect from 127.0.0.1 port 51566 to 127.0.0.1 port 15900, nchannels 7
debug1: Connection to port 15900 forwarding to 127.0.0.1 port 5900 requested.
debug1: channel 5: new [direct-tcpip]
debug1: channel 6: free: direct-tcpip: listening port 15900 for 127.0.0.1 port 5900, connect from 127.0.0.1 port 51567 to 127.0.0.1 port 15900, nchannels 7
debug1: channel 5: free: direct-tcpip: listening port 15900 for 127.0.0.1 port 5900, connect from 127.0.0.1 port 51569 to 127.0.0.1 port 15900, nchannels 6
This is from B's system log, filtered on connection attempts:
2023-08-18 08:52:05.095119+0200 0xe3cc3b Default 0x0 98235 0 screensharingd: SendAuthenticationInfoMessage
2023-08-18 08:52:05.126178+0200 0xe3cc3b Default 0x0 98235 0 screensharingd: HandleViewerAuthenticationMessages 2
2023-08-18 08:52:05.126193+0200 0xe3cc3b Default 0x0 98235 0 screensharingd: SendRSAResponseSRPAuthentication
2023-08-18 08:52:05.306678+0200 0xe3cc3b Default 0x0 98235 0 screensharingd: HandleViewerAuthenticationMessages 10
2023-08-18 08:52:05.306684+0200 0xe3cc3b Default 0x0 98235 0 screensharingd: SendRSAResponseSRPAuthentication
I don't see any obvious problems in these logs, are there? What can I do next to debug my problem?