@@ -84,6 +84,9 @@ func newSSHCmd(opts *Options) *cobra.Command {
8484 "-p" , fmt .Sprintf ("%d" , usedLocalPort ),
8585 "-o" , "StrictHostKeyChecking=no" ,
8686 "-o" , "UserKnownHostsFile=/dev/null" ,
87+ "-o" , "ServerAliveInterval=30" ,
88+ "-o" , "ServerAliveCountMax=10" ,
89+ "-o" , "TCPKeepAlive=yes" ,
8790 "-i" , keyPath ,
8891 }
8992 if cmdStr != "" {
@@ -214,7 +217,8 @@ func ensureSSHConfigEntry(hostAlias, sessionName, user string, localPort, remote
214217 }
215218 blockLines = append (blockLines ,
216219 " ServerAliveInterval 30" ,
217- " ServerAliveCountMax 3" ,
220+ " ServerAliveCountMax 10" ,
221+ " TCPKeepAlive yes" ,
218222 end ,
219223 )
220224 block := strings .Join (blockLines , "\n " ) + "\n "
@@ -370,6 +374,9 @@ func startManagedSSHForward(hostAlias string) error {
370374 "-S" , socketPath ,
371375 "-o" , "ControlPersist=600" ,
372376 "-o" , "ExitOnForwardFailure=yes" ,
377+ "-o" , "ServerAliveInterval=30" ,
378+ "-o" , "ServerAliveCountMax=10" ,
379+ "-o" , "TCPKeepAlive=yes" ,
373380 hostAlias ,
374381 )
375382 if out , err := cmd .CombinedOutput (); err != nil {
0 commit comments