From 6b6a18d38a74f14ee8a5206349ffda6e0255a595 Mon Sep 17 00:00:00 2001 From: Simon Roberts Date: Sun, 10 Oct 2021 08:26:21 +1100 Subject: [PATCH] Pass $HTTPS_PROXY to ssh server (#205) * Pass $HTTPS_PROXY to ssh server * Emit additional error when failing to set HostKeyFile --- pkg/ssh/server.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/ssh/server.go b/pkg/ssh/server.go index a59c955..55a0511 100644 --- a/pkg/ssh/server.go +++ b/pkg/ssh/server.go @@ -1,4 +1,5 @@ -//+build !windows +//go:build !windows +// +build !windows package ssh @@ -196,6 +197,9 @@ func (s *Server) ListenAndServe() error { cmd := exec.CommandContext(cmdCtx, s.executableBinary, flags...) cmd.Env = append(sshSession.Environ(), fmt.Sprintf("TERM=%s", ptyReq.Term)) + if proxy, ok := os.LookupEnv("HTTPS_PROXY"); ok { + cmd.Env = append(cmd.Env, fmt.Sprintf("HTTPS_PROXY=%s", proxy)) + } f, err := pty.Start(cmd) if err != nil { @@ -238,7 +242,7 @@ func (s *Server) ListenAndServe() error { err := s.sshServer.SetOption(ssh.HostKeyFile(s.hostKeyFile)) if err != nil { - return err + return fmt.Errorf("error setting HostKeyFile: %s: %v", s.hostKeyFile, err) } return s.sshServer.ListenAndServe()