From 8bb10f28b5dcb0f760c6120acdeaf50799f06674 Mon Sep 17 00:00:00 2001 From: Jinghui Hu Date: Sun, 17 Nov 2024 17:27:20 +0800 Subject: [PATCH] fix: when only provide password in config file, for example $ go build -o app $ ./app -c config.toml --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 9ae19cb..aa6df72 100644 --- a/main.go +++ b/main.go @@ -55,6 +55,9 @@ func main() { if user == "" { log.Fatal("user can not be empty") } + if len(cfg.Password) > 0 { + password = cfg.Password + } if password == "" && identityFile == "" { log.Fatal("password can not be empty") } @@ -64,6 +67,9 @@ func main() { log.Fatal("could not parse config file: ", err) } else { addr := fmt.Sprintf("%s:%d", cfg.Host, cfg.Port) + if len(cfg.Password) > 0 { + password = cfg.Password + } if password != "" { handler = &sshHandler{addr: addr, user: cfg.User, secret: cfg.Password} } else {