Skip to content

Commit

Permalink
Pass $HTTPS_PROXY to ssh server (#205)
Browse files Browse the repository at this point in the history
* Pass $HTTPS_PROXY to ssh server
* Emit additional error when failing to set HostKeyFile
  • Loading branch information
lyricnz authored Oct 9, 2021
1 parent dfaa8d0 commit 6b6a18d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/ssh/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !windows
//go:build !windows
// +build !windows

package ssh

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 6b6a18d

Please sign in to comment.