ipn/ipnlocal: flesh out error on ssh host key parse error

Change-Id: Iedd2d3898befa536181036b9e9dea59bc777a440
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/5123/head
Brad Fitzpatrick 2 years ago committed by Brad Fitzpatrick
parent 90ccba6730
commit 227c6b2a53

@ -117,7 +117,8 @@ func (b *LocalBackend) hostKeyFileOrCreate(keyDir, typ string) ([]byte, error) {
func (b *LocalBackend) getSystemSSH_HostKeys() (ret []ssh.Signer, err error) {
// TODO(bradfitz): cache this?
for _, typ := range keyTypes {
hostKey, err := ioutil.ReadFile("/etc/ssh/ssh_host_" + typ + "_key")
filename := "/etc/ssh/ssh_host_" + typ + "_key"
hostKey, err := ioutil.ReadFile(filename)
if os.IsNotExist(err) {
continue
}
@ -126,7 +127,7 @@ func (b *LocalBackend) getSystemSSH_HostKeys() (ret []ssh.Signer, err error) {
}
signer, err := ssh.ParsePrivateKey(hostKey)
if err != nil {
return nil, err
return nil, fmt.Errorf("error reading private key %s: %w", filename, err)
}
ret = append(ret, signer)
}

Loading…
Cancel
Save