Fix ssh keygen
This commit is contained in:
parent
61d490d5a0
commit
b4cbf63d6d
|
@ -3,7 +3,6 @@ package ssh
|
||||||
import (
|
import (
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/x509"
|
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
@ -21,14 +20,20 @@ func NewSSHKeyCipher(name string, keyring *crypto.Keyring) (models.Cipher, strin
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
privateKey, err := x509.MarshalPKCS8PrivateKey(priv)
|
|
||||||
privBlock := pem.Block{
|
privBlock := pem.Block{
|
||||||
Type: "OPENSSH PRIVATE KEY",
|
Type: "OPENSSH PRIVATE KEY",
|
||||||
Bytes: edkey.MarshalED25519PrivateKey(privateKey),
|
Bytes: edkey.MarshalED25519PrivateKey(priv),
|
||||||
}
|
}
|
||||||
|
|
||||||
privatePEM := pem.EncodeToMemory(&privBlock)
|
privatePEM := pem.EncodeToMemory(&privBlock)
|
||||||
publicKey, err := ssh.NewPublicKey(pub)
|
publicKey, err := ssh.NewPublicKey(pub)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Generation of public key failed: %s", err)
|
||||||
|
}
|
||||||
|
_, err = ssh.ParsePrivateKey([]byte(string(privatePEM)))
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Verification of generated private key failed: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
encryptedName, _ := crypto.EncryptWith([]byte(name), crypto.AesCbc256_HmacSha256_B64, keyring.GetAccountKey())
|
encryptedName, _ := crypto.EncryptWith([]byte(name), crypto.AesCbc256_HmacSha256_B64, keyring.GetAccountKey())
|
||||||
encryptedPublicKeyKey, _ := crypto.EncryptWith([]byte("public-key"), crypto.AesCbc256_HmacSha256_B64, keyring.GetAccountKey())
|
encryptedPublicKeyKey, _ := crypto.EncryptWith([]byte("public-key"), crypto.AesCbc256_HmacSha256_B64, keyring.GetAccountKey())
|
||||||
|
|
Loading…
Reference in New Issue