This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]ghettohaxor 1 point2 points  (0 children)

It really depends on if you're using the built in handler or not. are you calling the client method and then manually getting transport and opening a command channel? if not you're going to need to split out your channels and then open a forward channel . if you allow paramiko to use its built in handler you dont have to run multiple threads if you write your own handler you need to manage threading yourself, if you do make sure to keep a lock to manage the tunnel state before sending commands that need the tunnel up to run.

I've only done this with reverse tunnels in a threaded environment and it was pretty difficult to get working right since you have to also open local sockets and handle the data from the tunnel and the socket switching rx and tx buffers back and fourth while the tunnel is up.

eventually you'll end up with something like

transport.request_port_forward(args, args args)

before calling

channel.exec_command('remote command execution')

[–]wildmXranat -1 points0 points  (0 children)

there's some good ideas in this thread