Port forwarding for "remote debugger" (via ssh)
I'm trying to remote debug behind a somewhat non-standard ssh server. I have the source and am perfectly capable of hacking it to do what it needs to, but am having problems working out what it needs to do.
Launching remotely proves no problem and the various parts of "project interpreter" fill themselves in correctly. When the remote debugger launches it launches with:
ssh://root@localhost:2222/usr/bin/python3 -u /.pycharm_helpers/pydev/pydevd.py --multiproc
--save-signatures --client '0.0.0.0' --port 58037 --file replay.py
Where localhost:2222 is the ssh server. I can see from the logs that the ssh is asked to port forward 58037 and I'm currently assuming this is the "from remote to local" direction and am running a small proxy remotely. The remote connections look all good:
ctr-3nwVYxrgWv3sZKnniRzhXo:~# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:34720 127.0.0.1:58037 ESTABLISHED
tcp 0 0 127.0.0.1:58037 127.0.0.1:34720 ESTABLISHED
But locally something has gone wrong and PyCharm is listening on two different ports:
dpreece@davermbp ~> netstat -an | grep LISTEN
tcp4 0 0 *.51179 *.* LISTEN
tcp4 0 0 *.51176 *.* LISTEN
tcp4 0 0 *.2222 *.* LISTEN
tcp4 0 0 127.0.0.1.63342 *.* LISTEN
tcp4 0 0 127.0.0.1.6942 *.* LISTEN
tcp4 0 0 127.0.0.1.4380 *.* LISTEN
tcp4 0 0 127.0.0.1.4370 *.* LISTEN
tcp6 0 0 *.3689 *.* LISTEN
tcp4 0 0 *.3689 *.* LISTEN
tcp6 0 0 fd6f:2800:d7dd:4.4488 *.* LISTEN
tcp4 0 0 *.3260 *.* LISTEN
By sniffing packets from a local debug session I can see that the debugger would normally connect to the "first' port (say 51176) and this would send a control message that would cause the connection to forward to the second port (say 51179).
What I don't understand is how I'm supposed to derive "incoming port is 51176" with the port forwarding request being for 58037.
One more thing: Running a local session gives...
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Developer/PyCharm.app/Contents/helpers/pydev/pydevd.py --multiproc --qt-support --client 127.0.0.1 --port 51408 --file tfnz/cli/tf.py -svz -m pycharm_helpers:/.pycharm_helpers f4707dba2622
Causes a connection to happen on port 51408 the contents of which are:
99 -1 51409
And we can see this has been used to create a connection to port 51409
dpreece@davermbp ~/2/20ft> netstat -an | grep ESTABLISHED
tcp4 0 0 10.100.1.236.51418 17.167.192.231.443 ESTABLISHED
tcp4 0 0 10.100.1.236.51413 203.86.207.90.5555 ESTABLISHED
tcp4 0 0 127.0.0.1.51409 127.0.0.1.51411 ESTABLISHED
tcp4 0 0 127.0.0.1.51411 127.0.0.1.51409 ESTABLISHED
[snip]
In other words, for the local case it does what you'd expect it to - namely connect to the port passed in the '--port' parameter.
Does anyone have any idea what's going on?
Thanks,
Dave
请先登录再写评论。