mirror of https://github.com/slackhq/nebula.git
Support inlined sshd host key (#1054)
This commit is contained in:
parent
3210198276
commit
1f83d1758d
15
ssh.go
15
ssh.go
|
@ -90,14 +90,19 @@ func configSSH(l *logrus.Logger, ssh *sshd.SSHServer, c *config.C) (func(), erro
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: no good way to reload this right now
|
//TODO: no good way to reload this right now
|
||||||
hostKeyFile := c.GetString("sshd.host_key", "")
|
hostKeyPathOrKey := c.GetString("sshd.host_key", "")
|
||||||
if hostKeyFile == "" {
|
if hostKeyPathOrKey == "" {
|
||||||
return nil, fmt.Errorf("sshd.host_key must be provided")
|
return nil, fmt.Errorf("sshd.host_key must be provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
hostKeyBytes, err := os.ReadFile(hostKeyFile)
|
var hostKeyBytes []byte
|
||||||
if err != nil {
|
if strings.Contains(hostKeyPathOrKey, "-----BEGIN") {
|
||||||
return nil, fmt.Errorf("error while loading sshd.host_key file: %s", err)
|
hostKeyBytes = []byte(hostKeyPathOrKey)
|
||||||
|
} else {
|
||||||
|
hostKeyBytes, err = os.ReadFile(hostKeyPathOrKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error while loading sshd.host_key file: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ssh.SetHostKey(hostKeyBytes)
|
err = ssh.SetHostKey(hostKeyBytes)
|
||||||
|
|
Loading…
Reference in New Issue