diff options
author | Igor Drozdov <idrozdov@gitlab.com> | 2022-05-21 04:58:00 +0000 |
---|---|---|
committer | Igor Drozdov <idrozdov@gitlab.com> | 2022-05-21 04:58:00 +0000 |
commit | 569ae36d384b587127f47b72985a5cbbb0f118b7 (patch) | |
tree | c7523b6f50fe3c11f6e7a0539b62243617dfdd3f | |
parent | 0605bc42d04634e4b3097fddd38d60cc5183742e (diff) | |
parent | 587603934c24ca3760b3662ba93e24d1dbbdc483 (diff) | |
download | gitlab-shell-569ae36d384b587127f47b72985a5cbbb0f118b7.tar.gz |
Merge branch 'sh-downgrade-host-key-errors' into 'main'
Downgrade host key mismatch messages from warning to debug
See merge request gitlab-org/gitlab-shell!639
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | internal/sshd/sshd.go | 17 |
2 files changed, 16 insertions, 3 deletions
@@ -11,6 +11,7 @@ require ( github.com/otiai10/copy v1.4.2 github.com/pires/go-proxyproto v0.6.2 github.com/prometheus/client_golang v1.12.1 + github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 gitlab.com/gitlab-org/gitaly/v14 v14.9.0-rc5.0.20220329111719-51da8bc17059 gitlab.com/gitlab-org/labkit v1.14.0 @@ -59,7 +60,6 @@ require ( github.com/prometheus/procfs v0.7.3 // indirect github.com/sebest/xff v0.0.0-20210106013422-671bd2870b3a // indirect github.com/shirou/gopsutil/v3 v3.21.2 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect github.com/tinylib/msgp v1.1.2 // indirect github.com/tklauser/go-sysconf v0.3.4 // indirect github.com/tklauser/numcpus v0.2.1 // indirect diff --git a/internal/sshd/sshd.go b/internal/sshd/sshd.go index 4d4d6d5..80e87e0 100644 --- a/internal/sshd/sshd.go +++ b/internal/sshd/sshd.go @@ -10,6 +10,7 @@ import ( "time" "github.com/pires/go-proxyproto" + "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh" "gitlab.com/gitlab-org/gitlab-shell/internal/config" @@ -38,6 +39,18 @@ type Server struct { serverConfig *serverConfig } +func logSSHInitError(ctxlog *logrus.Entry, err error) { + msg := "server: handleConn: failed to initialize SSH connection" + + logger := ctxlog.WithError(err) + + if strings.Contains(err.Error(), "no common algorithm for host key") { + logger.Debug(msg) + } else { + logger.Warn(msg) + } +} + func NewServer(cfg *config.Config) (*Server, error) { serverConfig, err := newServerConfig(cfg) if err != nil { @@ -168,11 +181,11 @@ func (s *Server) handleConn(ctx context.Context, nconn net.Conn) { } }() - ctxlog.Info("server: handleConn: start") + ctxlog.Debug("server: handleConn: start") sconn, chans, reqs, err := ssh.NewServerConn(nconn, s.serverConfig.get(ctx)) if err != nil { - ctxlog.WithError(err).Warn("server: handleConn: failed to initialize SSH connection") + logSSHInitError(ctxlog, err) return } go ssh.DiscardRequests(reqs) |