Skip to content

Commit ec2b79a

Browse files
committed
Fix bug with defer in add ssh key
1 parent 90dc72e commit ec2b79a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/deploy/deploy.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ func UploadSSHKey(vulnbox common.Vulnbox, key string, keyfile string) error {
5353
if err != nil {
5454
return err
5555
}
56-
if err := client.Close(); err != nil {
57-
logrus.Errorf("Error closing client: %v", err)
58-
}
56+
defer func() {
57+
if err := sftpClient.Close(); err != nil {
58+
logrus.Errorf("Error closing client: %v", err)
59+
}
60+
}()
5961

6062
authkeys, err := sftpClient.OpenFile(".ssh/authorized_keys", os.O_APPEND|os.O_CREATE|os.O_WRONLY)
6163
if err != nil {

0 commit comments

Comments
 (0)