Skip to content

Commit

Permalink
Enable ssh keepalive to avoid "broken pipe" errors for long-running c…
Browse files Browse the repository at this point in the history
…ommands
  • Loading branch information
Matt Jurik authored and rzvoncek committed May 5, 2020
1 parent fd4cfdc commit 8dba321
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cstar/remote_paramiko.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def _connect(self):
debug("Id file: ", self.ssh_identity_file)
self.client.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
self.client.connect(self.hostname, compress=True, username=self.ssh_username, password=self.ssh_password, pkey=pkey)

# Enable keepalive to improve connection stability when running commands that return no output for
# long periods of time.
transport = self.client.get_transport()
transport.set_keepalive(5)
except:
self.client = None
raise BadSSHHost("Could not establish an SSH connection to host %s" % (self.hostname,))
Expand Down

0 comments on commit 8dba321

Please sign in to comment.