Skip to content

Commit

Permalink
Fixed variable initialization issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Briaker authored and nicklasfrahm committed Nov 11, 2021
1 parent 2089d4d commit 56a6854
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 56a6854

Please sign in to comment.