-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
52 lines (40 loc) · 879 Bytes
/
main.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"log"
"github.com/42wim/ssh-agentx/yubikey"
"github.com/spf13/viper"
"golang.org/x/crypto/ssh/agent"
)
var agentName = "ssh-agentx"
func main() {
ag := &SSHAgent{
ExtendedAgent: agent.NewKeyring().(agent.ExtendedAgent),
}
v, err := ag.parseConfig()
if err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
fmt.Println("# config file not found, continuing as normal ssh-agent")
} else {
log.Fatal(err)
}
}
if v.GetBool("yubikey.enable") {
yubi, err := yubikey.New()
if err != nil {
panic(err)
}
if v.GetBool("yubikey.enablelog") {
log.Println("setting slot to", v.GetString("yubikey.defaultslot"))
}
yubi.SetSlot(v.GetString("yubikey.defaultslot"))
y, err := yubi.CreateSigner()
if err != nil {
panic(err)
}
ag.yubikey = yubi
ag.yubisigner = y
}
ag.v = v
ag.start()
}