Skip to content

Commit 8dba321

Browse files
Matt Jurikrzvoncek
authored andcommitted
Enable ssh keepalive to avoid "broken pipe" errors for long-running commands
1 parent fd4cfdc commit 8dba321

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cstar/remote_paramiko.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ def _connect(self):
6464
debug("Id file: ", self.ssh_identity_file)
6565
self.client.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
6666
self.client.connect(self.hostname, compress=True, username=self.ssh_username, password=self.ssh_password, pkey=pkey)
67+
68+
# Enable keepalive to improve connection stability when running commands that return no output for
69+
# long periods of time.
70+
transport = self.client.get_transport()
71+
transport.set_keepalive(5)
6772
except:
6873
self.client = None
6974
raise BadSSHHost("Could not establish an SSH connection to host %s" % (self.hostname,))

0 commit comments

Comments
 (0)