the paramiko demo files include file called rforward py that does exactly this it works perfectly as is so won' just reprint that filebut will point out couple of important points and run through an example of how to use it open rforward pyskip down to main()and follow along def main()optionsserverremote parse_options(password none if options readpasspassword getpass getpass('enter ssh password'client paramiko sshclient(client load_system_host_keys(client set_missing_host_key_policy(paramiko warningpolicy()verbose('connecting to ssh host % :% (server[ ]server[ ])tryclient connect(server[ ]server[ ]username=options userkey_filename=options keyfilelook_for_keys=options look_for_keyspassword=passwordexcept exception as eprint('**failed to connect to % :% % (server[ ]server[ ] )sys exit( verbose('now forwarding remote port % to % :% (options portremote[ ]remote[ ])tryreverse_forward_tunnel(options portremote[ ]remote[ ]client get_transport()except keyboardinterruptprint(' -cport forwarding stopped 'sys exit( the few lines at the top double-check to make sure all the necessary arguments are passed to the script before setting up the parmakio ssh client connection (which should look very familiarthe final section in main(calls the reverse_forward_tunnel function let' have look at that function def reverse_forward_tunnel(server_portremote_hostremote_porttransport)transport request_port_forward(''server_portwhile truechan transport accept( if chan is nonecontinue