ipn/ipnlocal: ignore empty SSH host key files

Change-Id: I332b0d7d01386111d0af4adf98c96c04d3d12fbb
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/5126/head
Brad Fitzpatrick 2 years ago committed by Brad Fitzpatrick
parent 227c6b2a53
commit ba91f57ddd

@ -8,6 +8,7 @@
package ipnlocal package ipnlocal
import ( import (
"bytes"
"crypto/ecdsa" "crypto/ecdsa"
"crypto/ed25519" "crypto/ed25519"
"crypto/elliptic" "crypto/elliptic"
@ -119,7 +120,7 @@ func (b *LocalBackend) getSystemSSH_HostKeys() (ret []ssh.Signer, err error) {
for _, typ := range keyTypes { for _, typ := range keyTypes {
filename := "/etc/ssh/ssh_host_" + typ + "_key" filename := "/etc/ssh/ssh_host_" + typ + "_key"
hostKey, err := ioutil.ReadFile(filename) hostKey, err := ioutil.ReadFile(filename)
if os.IsNotExist(err) { if os.IsNotExist(err) || len(bytes.TrimSpace(hostKey)) == 0 {
continue continue
} }
if err != nil { if err != nil {

Loading…
Cancel
Save