@@ -11,6 +11,7 @@ import (
1111 "path/filepath"
1212 "strings"
1313 "sync"
14+ "syscall"
1415 "time"
1516
1617 "github.com/acmore/okdev/internal/config"
@@ -228,6 +229,7 @@ func ensureSSHConfigEntry(hostAlias, sessionName, namespace, user string, remote
228229 " ServerAliveInterval 30" ,
229230 " ServerAliveCountMax 10" ,
230231 " TCPKeepAlive yes" ,
232+ " LogLevel ERROR" ,
231233 end ,
232234 )
233235 block := strings .Join (blockLines , "\n " ) + "\n "
@@ -305,7 +307,7 @@ func newSSHProxyCmd(opts *Options) *cobra.Command {
305307 var copyErr error
306308 var once sync.Once
307309 setErr := func (err error ) {
308- if err == nil || errors .Is (err , io .EOF ) {
310+ if err == nil || errors .Is (err , io .EOF ) || errors . Is ( err , net . ErrClosed ) || errors . Is ( err , syscall . EPIPE ) || isIgnorableProxyIOError ( err ) {
309311 return
310312 }
311313 once .Do (func () { copyErr = err })
@@ -315,9 +317,6 @@ func newSSHProxyCmd(opts *Options) *cobra.Command {
315317 defer wg .Done ()
316318 _ , err := io .Copy (conn , os .Stdin )
317319 setErr (err )
318- if cw , ok := conn .(interface { CloseWrite () error }); ok {
319- _ = cw .CloseWrite ()
320- }
321320 }()
322321 go func () {
323322 defer wg .Done ()
@@ -332,6 +331,16 @@ func newSSHProxyCmd(opts *Options) *cobra.Command {
332331 return cmd
333332}
334333
334+ func isIgnorableProxyIOError (err error ) bool {
335+ if err == nil {
336+ return true
337+ }
338+ msg := strings .ToLower (err .Error ())
339+ return strings .Contains (msg , "broken pipe" ) ||
340+ strings .Contains (msg , "use of closed network connection" ) ||
341+ strings .Contains (msg , "connection reset by peer" )
342+ }
343+
335344func waitDialLocal (localPort int , timeout time.Duration ) (net.Conn , error ) {
336345 deadline := time .Now ().Add (timeout )
337346 addr := fmt .Sprintf ("127.0.0.1:%d" , localPort )
@@ -377,10 +386,11 @@ func startManagedSSHForward(hostAlias string) error {
377386 "-M" ,
378387 "-S" , socketPath ,
379388 "-o" , "ControlPersist=600" ,
380- "-o" , "ExitOnForwardFailure=yes " ,
389+ "-o" , "ExitOnForwardFailure=no " ,
381390 "-o" , "ServerAliveInterval=30" ,
382391 "-o" , "ServerAliveCountMax=10" ,
383392 "-o" , "TCPKeepAlive=yes" ,
393+ "-o" , "LogLevel=ERROR" ,
384394 hostAlias ,
385395 )
386396 if out , err := cmd .CombinedOutput (); err != nil {
0 commit comments