Compare commits
No commits in common. "4edc9ff2abacbcc66597e6f1a002d6d484d2b5fd" and "c006b7d8f9e5751a4525e6c6fdb42d58a8e09af4" have entirely different histories.
4edc9ff2ab
...
c006b7d8f9
17
main.go
17
main.go
@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Dossier racine SFTP (tu montes déjà ton volume ici dans Docker)
|
// Dossier racine SFTP (tu montes déjà ton volume ici dans Docker)
|
||||||
SFTPBaseDir = "upload"
|
SFTPBaseDir = "/upload"
|
||||||
|
|
||||||
// Identifiants standards (utilisés si IP non autorisée)
|
// Identifiants standards (utilisés si IP non autorisée)
|
||||||
LoginUser = "cangui2089"
|
LoginUser = "cangui2089"
|
||||||
@ -270,3 +270,18 @@ func main() {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
func loadOrCreateRSAHostKey(path string) (ssh.Signer, error) {
|
||||||
|
if _, err := os.Stat(path); err == nil {
|
||||||
|
b, err := os.ReadFile(path)
|
||||||
|
if err != nil { return nil, err }
|
||||||
|
return ssh.ParsePrivateKey(b)
|
||||||
|
}
|
||||||
|
// Génère une clé RSA 2048
|
||||||
|
priv, err := rsa.GenerateKey(rand.Reader, 2048)
|
||||||
|
if err != nil { return nil, err }
|
||||||
|
// Encode en PEM "RSA PRIVATE KEY" (PKCS#1)
|
||||||
|
pkcs1 := x509.MarshalPKCS1PrivateKey(priv)
|
||||||
|
pemBytes := pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: pkcs1})
|
||||||
|
if err := os.WriteFile(path, pemBytes, 0o600); err != nil { return nil, err }
|
||||||
|
return ssh.ParsePrivateKey(pemBytes)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user