From 7b95dde25f28512b1343e42a9fb4a858f8cbcc1b Mon Sep 17 00:00:00 2001 From: Mickael Kerjean Date: Mon, 31 Jan 2022 23:31:17 +1100 Subject: [PATCH] fix (#426): username case sensitive on sftp better strategy is to: 1. attempt the login "as is" 2. attempt the lowercase version in case of error --- server/plugin/plg_backend_sftp/index.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/plugin/plg_backend_sftp/index.go b/server/plugin/plg_backend_sftp/index.go index ae21108a..8c47add1 100644 --- a/server/plugin/plg_backend_sftp/index.go +++ b/server/plugin/plg_backend_sftp/index.go @@ -38,7 +38,7 @@ func (s Sftp) Init(params map[string]string, app *App) (IBackend, error) { }{ params["hostname"], params["port"], - strings.ToLower(params["username"]), + params["username"], params["password"], params["passphrase"], } @@ -126,7 +126,11 @@ func (s Sftp) Init(params map[string]string, app *App) (IBackend, error) { client, err := ssh.Dial("tcp", addr, config) if err != nil { - return &s, ErrAuthenticationFailed + config.User = strings.ToLower(p.username) + client, err = ssh.Dial("tcp", addr, config) + if err != nil { + return &s, ErrAuthenticationFailed + } } s.SSHClient = client