ssh: load more host key formats than rsa
This commit is contained in:
parent
d69f2f27ee
commit
82afd9492a
16
ssh.go
16
ssh.go
@ -23,17 +23,27 @@ func startSSH(cfg *config.Config) {
|
||||
PublicKeyCallback: sshCheckPubkey,
|
||||
}
|
||||
|
||||
pkBytes, err := os.ReadFile("/id_rsa") // TODO configurable
|
||||
hostKeyLoaded := false
|
||||
|
||||
for _, format := range []string{"rsa", "dsa", "ecdsa", "ed25519"} {
|
||||
pkBytes, err := os.ReadFile("/id_" + format)
|
||||
if err != nil {
|
||||
fatalf("ssh: failed to load private key: %v", err)
|
||||
log.Printf("ssh : failed to load %s host key: %v", format, err)
|
||||
continue
|
||||
}
|
||||
|
||||
pk, err := ssh.ParsePrivateKey(pkBytes)
|
||||
if err != nil {
|
||||
fatalf("ssh: failed to parse private key: %v", err)
|
||||
log.Printf("ssh: failed to parse %s host key: %v", format, err)
|
||||
continue
|
||||
}
|
||||
|
||||
sshConfig.AddHostKey(pk)
|
||||
}
|
||||
|
||||
if !hostKeyLoaded {
|
||||
fatalf("ssh: failed to load any host key")
|
||||
}
|
||||
|
||||
sshBind := ":22" // TODO configurable
|
||||
listener, err := net.Listen("tcp", sshBind)
|
||||
|
Loading…
Reference in New Issue
Block a user