From ff849cd4f848b7530e42567aead8c80ae92e8a17 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 23 Jan 2024 04:25:25 -0500 Subject: [PATCH] fix: touch the known hosts file earlier --- plugins/common/ssh.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/common/ssh.go b/plugins/common/ssh.go index 0c405d448..7d26e089b 100644 --- a/plugins/common/ssh.go +++ b/plugins/common/ssh.go @@ -244,6 +244,10 @@ func (task SshTask) Execute(ctx context.Context) (SshResult, error) { task.Port = 22 } + if err := TouchFile(filepath.Join(os.Getenv("DOKKU_ROOT"), ".ssh", "known_hosts")); err != nil { + return SshResult{}, fmt.Errorf("failed to touch known_hosts file: %w", err) + } + auth, err := goph.Key(task.SshKeyPath, "") if err != nil { return SshResult{}, fmt.Errorf("failed to load ssh key: %w", err) @@ -254,10 +258,6 @@ func (task SshTask) Execute(ctx context.Context) (SshResult, error) { return SshResult{}, fmt.Errorf("failed to load known hosts: %w", err) } - if err := TouchFile(filepath.Join(os.Getenv("DOKKU_ROOT"), ".ssh", "known_hosts")); err != nil { - return SshResult{}, fmt.Errorf("failed to touch known_hosts file: %w", err) - } - if task.AllowUknownHosts { callback = ssh.InsecureIgnoreHostKey() }