From 6dc4357da5797fe1e2bc3dadfd4a8dd72d38bfee Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Fri, 24 Jun 2016 15:24:36 +0200 Subject: [PATCH] ssh: workaround to not block Stdin from returning corrrectly Assign session.stdin using StdinPipe() to avoid cases of ssh connetions being blocked on user input. WIP. Reported-by: kayrus maybe partly resolves https://github.com/coreos/fleet/issues/1499 --- ssh/ssh.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ssh/ssh.go b/ssh/ssh.go index 82ac70601..3e1251384 100644 --- a/ssh/ssh.go +++ b/ssh/ssh.go @@ -16,6 +16,7 @@ package ssh import ( "errors" + "io" "net" "os" "strconv" @@ -72,7 +73,17 @@ func makeSession(client *SSHForwardingClient) (session *gossh.Session, finalize session.Stdout = os.Stdout session.Stderr = os.Stderr - session.Stdin = os.Stdin + + // Workaround to not prevent Stdin from returning. + inPipe, err := session.StdinPipe() + if err != nil { + return + } + + go func() { + io.Copy(inPipe, os.Stdin) + inPipe.Close() + }() modes := gossh.TerminalModes{ gossh.ECHO: 1, // enable echoing