serve sftp: fix generation of server keys on windows

This commit is contained in:
albertony 2021-10-10 14:35:57 +02:00 committed by Nick Craig-Wood
parent ada6a92c8b
commit 894a5a1a83

View file

@ -239,14 +239,14 @@ func (s *server) serve() (err error) {
if err != nil { if err != nil {
return errors.Wrap(err, "failed to create cache path") return errors.Wrap(err, "failed to create cache path")
} }
if strings.HasSuffix(keyPath, "/id_rsa") { if strings.HasSuffix(keyPath, string(os.PathSeparator)+"id_rsa") {
const bits = 2048 const bits = 2048
fs.Logf(nil, "Generating %d bit key pair at %q", bits, keyPath) fs.Logf(nil, "Generating %d bit key pair at %q", bits, keyPath)
err = makeRSASSHKeyPair(bits, keyPath+".pub", keyPath) err = makeRSASSHKeyPair(bits, keyPath+".pub", keyPath)
} else if strings.HasSuffix(keyPath, "/id_ecdsa") { } else if strings.HasSuffix(keyPath, string(os.PathSeparator)+"id_ecdsa") {
fs.Logf(nil, "Generating ECDSA p256 key pair at %q", keyPath) fs.Logf(nil, "Generating ECDSA p256 key pair at %q", keyPath)
err = makeECDSASSHKeyPair(keyPath+".pub", keyPath) err = makeECDSASSHKeyPair(keyPath+".pub", keyPath)
} else if strings.HasSuffix(keyPath, "/id_ed25519") { } else if strings.HasSuffix(keyPath, string(os.PathSeparator)+"id_ed25519") {
fs.Logf(nil, "Generating Ed25519 key pair at %q", keyPath) fs.Logf(nil, "Generating Ed25519 key pair at %q", keyPath)
err = makeEd25519SSHKeyPair(keyPath+".pub", keyPath) err = makeEd25519SSHKeyPair(keyPath+".pub", keyPath)
} else { } else {