Skip to content
11 changes: 9 additions & 2 deletions st2common/st2common/runners/paramiko_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def __init__(self, hostname, port=DEFAULT_SSH_PORT, username=None, password=None

self.bastion_client = None
self.bastion_socket = None
self.socket = None
Comment thread
punkrokk marked this conversation as resolved.

def connect(self):
"""
Expand Down Expand Up @@ -455,6 +456,12 @@ def close(self):

self.client.close()

if self.socket:
self.logger.debug('Closing proxycommand socket connection')
#https://github.com/paramiko/paramiko/issues/789 Avoid zombie ssh processes
Comment thread
punkrokk marked this conversation as resolved.
Outdated
self.socket.process.kill()
self.socket.process.poll()

if self.sftp_client:
self.sftp_client.close()

Expand Down Expand Up @@ -698,8 +705,8 @@ def _connect(self, host, socket=None):
'_username': self.username, '_timeout': self.timeout}
self.logger.debug('Connecting to server', extra=extra)

socket = socket or ssh_config_file_info.get('sock', None)
if socket:
self.socket = self.socket or ssh_config_file_info.get('sock', None)
Comment thread
blag marked this conversation as resolved.
Outdated
if self.socket:
conninfo['sock'] = socket

client = paramiko.SSHClient()
Expand Down