Skip to content

Commit 6e567f2

Browse files
authored
Merge pull request antoniomika#73 from antoniomika/ed25519_auth
Change host key to ed25519 based auth
2 parents 8bcef9c + 837951d commit 6e567f2

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/koding/websocketproxy v0.0.0-20181220232114-7ed82d81a28c
1212
github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23
1313
github.com/mattn/go-isatty v0.0.10 // indirect
14+
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a
1415
github.com/oschwald/maxminddb-golang v1.5.0 // indirect
1516
github.com/pires/go-proxyproto v0.0.0-20190615163442-2c19fd512994
1617
github.com/ugorji/go v1.1.7 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23/go.mod h1:7rIyQ
2727
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
2828
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
2929
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
30+
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a h1:eU8j/ClY2Ty3qdHnn0TyW3ivFoPC/0F1gQZz8yTxbbE=
31+
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a/go.mod h1:v8eSC2SMp9/7FTKUncp7fH9IwPfw+ysMObcEz5FWheQ=
3032
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
3133
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
3234
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=

utils.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package main
22

33
import (
44
"bytes"
5+
"crypto/ed25519"
56
"crypto/rand"
6-
"crypto/rsa"
77
"crypto/x509"
88
"encoding/pem"
99
"fmt"
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/fsnotify/fsnotify"
2323
"github.com/logrusorgru/aurora"
24+
"github.com/mikesmitty/edkey"
2425
"golang.org/x/crypto/ssh"
2526
)
2627

@@ -226,16 +227,16 @@ func getSSHConfig() *ssh.ServerConfig {
226227
}
227228

228229
func generatePrivateKey(passphrase string) []byte {
229-
pk, err := rsa.GenerateKey(rand.Reader, 2048)
230+
_, pk, err := ed25519.GenerateKey(rand.Reader)
230231
if err != nil {
231232
log.Fatal(err)
232233
}
233234

234235
log.Println("Generated RSA Keypair")
235236

236237
pemBlock := &pem.Block{
237-
Type: "RSA PRIVATE KEY",
238-
Bytes: x509.MarshalPKCS1PrivateKey(pk),
238+
Type: "OPENSSH PRIVATE KEY",
239+
Bytes: edkey.MarshalED25519PrivateKey(pk),
239240
}
240241

241242
var pemData []byte

0 commit comments

Comments
 (0)