-
Notifications
You must be signed in to change notification settings - Fork 2
/
sshkeys.go
36 lines (27 loc) · 1.04 KB
/
sshkeys.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"log"
"os"
"github.com/dpecos/sshkeys/config"
"github.com/dpecos/sshkeys/utils"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
var (
app = kingpin.New("sshkeys", "Deploy SSH keys to remote hosts")
configFile = app.Flag("config", "Configuration file specifying hosts, grants and ACLs").Required().String()
privateKey = app.Flag("privateKey", "Private key to use to upload authorized_keys file to remote hosts").Required().String()
keyring = app.Flag("keyring", "Path to a folder containing all user public keys (each one as a separate file named like user.pub)").Required().String()
deploy = app.Command("deploy", "Generate and upload an authorized_keys file to remote hosts defined in configuation file")
)
func main() {
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
case deploy.FullCommand():
hosts, acls, err := config.LoadConfig(*configFile)
if err != nil {
log.Panic(err)
}
if err := utils.UploadKeys(*privateKey, *keyring, hosts, acls); err != nil {
log.Fatalf("ERROR: %s\n", err)
}
}
}