Skip to content

Commit

Permalink
Change host key to ed25519 based auth
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika committed Feb 14, 2020
1 parent 2df6c4b commit 837951d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/koding/websocketproxy v0.0.0-20181220232114-7ed82d81a28c
github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a
github.com/oschwald/maxminddb-golang v1.5.0 // indirect
github.com/pires/go-proxyproto v0.0.0-20190615163442-2c19fd512994
github.com/ugorji/go v1.1.7 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23/go.mod h1:7rIyQ
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a h1:eU8j/ClY2Ty3qdHnn0TyW3ivFoPC/0F1gQZz8yTxbbE=
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a/go.mod h1:v8eSC2SMp9/7FTKUncp7fH9IwPfw+ysMObcEz5FWheQ=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
9 changes: 5 additions & 4 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"bytes"
"crypto/ed25519"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
Expand All @@ -21,6 +21,7 @@ import (

"github.com/fsnotify/fsnotify"
"github.com/logrusorgru/aurora"
"github.com/mikesmitty/edkey"
"golang.org/x/crypto/ssh"
)

Expand Down Expand Up @@ -226,16 +227,16 @@ func getSSHConfig() *ssh.ServerConfig {
}

func generatePrivateKey(passphrase string) []byte {
pk, err := rsa.GenerateKey(rand.Reader, 2048)
_, pk, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
log.Fatal(err)
}

log.Println("Generated RSA Keypair")

pemBlock := &pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(pk),
Type: "OPENSSH PRIVATE KEY",
Bytes: edkey.MarshalED25519PrivateKey(pk),
}

var pemData []byte
Expand Down

0 comments on commit 837951d

Please sign in to comment.