6
6
"crypto/sha256"
7
7
"crypto/tls"
8
8
"crypto/x509"
9
+ "encoding/base64"
9
10
"encoding/json"
10
11
"encoding/pem"
11
12
"errors"
@@ -28,14 +29,13 @@ import (
28
29
"strings"
29
30
"syscall"
30
31
"time"
31
- "encoding/base64"
32
32
)
33
33
34
34
const (
35
35
AppVersion = "GoRTR 0.11.0"
36
36
37
37
ENV_SSH_PASSWORD = "RTR_SSH_PASSWORD"
38
- ENV_SSH_KEY = "GORTR_SSH_AUTHORIZEDKEYS"
38
+ ENV_SSH_KEY = "GORTR_SSH_AUTHORIZEDKEYS"
39
39
40
40
METHOD_NONE = iota
41
41
METHOD_PASSWORD
@@ -53,16 +53,16 @@ var (
53
53
TLSCert = flag .String ("tls.cert" , "" , "Certificate path" )
54
54
TLSKey = flag .String ("tls.key" , "" , "Private key path" )
55
55
56
- BindSSH = flag .String ("ssh.bind" , "" , "Bind address for SSH" )
57
- SSHKey = flag .String ("ssh.key" , "private.pem" , "SSH host key" )
56
+ BindSSH = flag .String ("ssh.bind" , "" , "Bind address for SSH" )
57
+ SSHKey = flag .String ("ssh.key" , "private.pem" , "SSH host key" )
58
58
59
- SSHAuthEnablePassword = flag .Bool ("ssh.method.password" , false , "Enable password auth" )
60
- SSHAuthUser = flag .String ("ssh.auth.user" , "rpki" , "SSH user" )
61
- SSHAuthPassword = flag .String ("ssh.auth.password" , "" , "SSH password (if blank, will use envvar GORTR_SSH_PASSWORD)" )
59
+ SSHAuthEnablePassword = flag .Bool ("ssh.method.password" , false , "Enable password auth" )
60
+ SSHAuthUser = flag .String ("ssh.auth.user" , "rpki" , "SSH user" )
61
+ SSHAuthPassword = flag .String ("ssh.auth.password" , "" , "SSH password (if blank, will use envvar GORTR_SSH_PASSWORD)" )
62
62
63
- SSHAuthEnableKey = flag .Bool ("ssh.method.key" , false , "Enable key auth" )
63
+ SSHAuthEnableKey = flag .Bool ("ssh.method.key" , false , "Enable key auth" )
64
64
SSHAuthKeysBypass = flag .Bool ("ssh.auth.key.bypass" , false , "Accept any SSH key" )
65
- SSHAuthKeysList = flag .String ("ssh.auth.key.file" , "" , "Authorized SSH key file (if blank, will use envvar GORTR_SSH_AUTHORIZEDKEYS" )
65
+ SSHAuthKeysList = flag .String ("ssh.auth.key.file" , "" , "Authorized SSH key file (if blank, will use envvar GORTR_SSH_AUTHORIZEDKEYS" )
66
66
67
67
TimeCheck = flag .Bool ("checktime" , true , "Check if file is still valid" )
68
68
Verify = flag .Bool ("verify" , true , "Check signature using provided public key" )
@@ -519,7 +519,7 @@ func main() {
519
519
var noKeys bool
520
520
for i , k := range sshClientKeys {
521
521
if strings .HasPrefix (fmt .Sprintf ("%v %v" , key .Type (), keyBase64 ), k ) {
522
- log .Infof ("Connected (ssh-key): %v/%v with key %v %v (matched with line %v)" ,
522
+ log .Infof ("Connected (ssh-key): %v/%v with key %v %v (matched with line %v)" ,
523
523
conn .User (), conn .RemoteAddr (), key .Type (), keyBase64 , i + 1 )
524
524
noKeys = true
525
525
break
@@ -538,7 +538,7 @@ func main() {
538
538
}, nil
539
539
}
540
540
}
541
-
541
+
542
542
if ! (* SSHAuthEnableKey || * SSHAuthEnablePassword ) {
543
543
sshConfig .NoClientAuth = true
544
544
}
0 commit comments