Shutting Down SSH Tunnel in Paramiko Programatically
Posted
by PlaidFan
on Stack Overflow
See other posts from Stack Overflow
or by PlaidFan
Published on 2010-05-06T01:33:57Z
Indexed on
2010/05/06
1:38 UTC
Read the original article
Hit count: 326
We are attempting to use the paramiko module for creating SSH tunnels on demand to arbitrary servers for purposes of querying remote databases. We attempted to use the forward.py demo that ships with paramiko but the big limitation is there does not seem to be an easy way to close an SSH tunnel and the SSH connection once the socket server is started up.
The limitation we have is that we cannot activate this from a shell and then kill the shell manually to stop the listner. We need to open the SSH connection, tunnel, perform some actions through the tunnel, close the tunnel, and close the SSH connection within python.
I've seen references to a server.shutdown() method but it isn't clear how to implement it correctly.
Any help would be greatly appreciated...
© Stack Overflow or respective owner