@@ -87,6 +87,14 @@ func (r *RootCmd) ssh() *clibase.Cmd {
87
87
}
88
88
}()
89
89
90
+ // In stdio mode, we can't allow any writes to stdin or stdout
91
+ // because they are used by the SSH protocol.
92
+ stdioReader ,stdioWriter := inv .Stdin ,inv .Stdout
93
+ if stdio {
94
+ inv .Stdin = stdioWarnReader {inv .Logger }
95
+ inv .Stdout = inv .Stderr
96
+ }
97
+
90
98
// This WaitGroup solves for a race condition where we were logging
91
99
// while closing the log file in a defer. It probably solves
92
100
// others too.
@@ -234,7 +242,7 @@ func (r *RootCmd) ssh() *clibase.Cmd {
234
242
if err != nil {
235
243
return xerrors .Errorf ("connect SSH: %w" ,err )
236
244
}
237
- copier := newRawSSHCopier (logger ,rawSSH ,inv . Stdin , inv . Stdout )
245
+ copier := newRawSSHCopier (logger ,rawSSH ,stdioReader , stdioWriter )
238
246
if err = stack .push ("rawSSHCopier" ,copier );err != nil {
239
247
return err
240
248
}
@@ -987,3 +995,12 @@ func sshDisableAutostartOption(src *clibase.Bool) clibase.Option {
987
995
Default :"false" ,
988
996
}
989
997
}
998
+
999
+ type stdioWarnReader struct {
1000
+ l slog.Logger
1001
+ }
1002
+
1003
+ func (r stdioWarnReader )Read (p []byte ) (n int ,err error ) {
1004
+ r .l .Warn (context .Background (),"reading from stdin in stdio mode is not supported" )
1005
+ return 0 ,io .EOF
1006
+ }