From abec574b76c22625aedbdfa533eafcd66f1a3aa9 Mon Sep 17 00:00:00 2001 From: Andrew Woodlee Date: Mon, 2 Jan 2023 14:55:18 -0600 Subject: [PATCH] more work on host key checking --- pkg/backy/ssh.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/backy/ssh.go b/pkg/backy/ssh.go index 4914e4f..d5c473b 100644 --- a/pkg/backy/ssh.go +++ b/pkg/backy/ssh.go @@ -60,6 +60,7 @@ func (remoteConfig *Host) ConnectToSSHHost() (*ssh.Client, error) { f, _ := os.Open(filepath.Join(os.Getenv("HOME"), ".ssh", "config")) cfg, _ := ssh_config.Decode(f) for _, host := range cfg.Hosts { + var hostKey ssh.PublicKey if host.Matches(remoteConfig.Host) { var identityFile string if remoteConfig.PrivateKeyPath == "" { @@ -90,10 +91,10 @@ func (remoteConfig *Host) ConnectToSSHHost() (*ssh.Client, error) { port = "22" } remoteConfig.HostName[index] = hostName + ":" + port + hostKey = getHostKey(hostName) println("HostName: " + remoteConfig.HostName[0]) } } - hostKey := getHostKey(remoteConfig.HostName[0]) privateKey, err := os.ReadFile(remoteConfig.PrivateKeyPath) if err != nil {