From 56a68540c43e869973ee38d90b8281f0f5929c08 Mon Sep 17 00:00:00 2001 From: Briaker Date: Thu, 11 Nov 2021 01:05:06 -0500 Subject: [PATCH] Fixed variable initialization issue --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 2a481bf..342e551 100644 --- a/main.go +++ b/main.go @@ -171,12 +171,17 @@ func Copy(client *ssh.Client) { func ConfigureAuthentication(key string, passphrase string, password string) []ssh.AuthMethod { // Create signer for public key authentication method. auth := make([]ssh.AuthMethod, 1) + if key != "" { + var err error + var targetSigner ssh.Signer + if passphrase != "" { - targetSigner, err := ssh.ParsePrivateKeyWithPassphrase([]byte(key), []byte(passphrase)) + targetSigner, err = ssh.ParsePrivateKeyWithPassphrase([]byte(key), []byte(passphrase)) } else { - targetSigner, err := ssh.ParsePrivateKey([]byte(key)) + targetSigner, err = ssh.ParsePrivateKey([]byte(key)) } + if err != nil { log.Fatalf("❌ Failed to parse private key: %v", err) }