From ba91f57ddd5c57ffb2aafe56cc3496141016b330 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 22 Jul 2022 10:41:21 -0700 Subject: [PATCH] ipn/ipnlocal: ignore empty SSH host key files Change-Id: I332b0d7d01386111d0af4adf98c96c04d3d12fbb Signed-off-by: Brad Fitzpatrick --- ipn/ipnlocal/ssh.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ipn/ipnlocal/ssh.go b/ipn/ipnlocal/ssh.go index c720afb25..221a80a7c 100644 --- a/ipn/ipnlocal/ssh.go +++ b/ipn/ipnlocal/ssh.go @@ -8,6 +8,7 @@ package ipnlocal import ( + "bytes" "crypto/ecdsa" "crypto/ed25519" "crypto/elliptic" @@ -119,7 +120,7 @@ func (b *LocalBackend) getSystemSSH_HostKeys() (ret []ssh.Signer, err error) { for _, typ := range keyTypes { filename := "/etc/ssh/ssh_host_" + typ + "_key" hostKey, err := ioutil.ReadFile(filename) - if os.IsNotExist(err) { + if os.IsNotExist(err) || len(bytes.TrimSpace(hostKey)) == 0 { continue } if err != nil {