@@ -4,23 +4,24 @@ import (
4
4
"os"
5
5
"path/filepath"
6
6
7
- "github.com/smallstep/cli/utils"
8
-
9
7
"github.com/pkg/errors"
10
8
"github.com/smallstep/certificates/templates"
9
+ "github.com/smallstep/cli/config"
11
10
"github.com/smallstep/cli/errs"
11
+ "github.com/smallstep/cli/utils"
12
12
)
13
13
14
14
// sshTemplates contains the configuration of default templates used on ssh.
15
+ // Relative paths are relative to the StepPath.
15
16
var sshTemplates = & templates.SSHTemplates {
16
17
User : []templates.Template {
17
- {Name : "include.tpl" , Type : templates .Snippet , TemplatePath : "ssh/include.tpl" , Path : "~/.ssh/config" , Comment : "#" },
18
- {Name : "config.tpl" , Type : templates .File , TemplatePath : "ssh/config.tpl" , Path : "ssh/config" , Comment : "#" },
19
- {Name : "known_hosts.tpl" , Type : templates .File , TemplatePath : "ssh/known_hosts.tpl" , Path : "ssh/known_hosts" , Comment : "#" },
18
+ {Name : "include.tpl" , Type : templates .Snippet , TemplatePath : "templates/ ssh/include.tpl" , Path : "~/.ssh/config" , Comment : "#" },
19
+ {Name : "config.tpl" , Type : templates .File , TemplatePath : "templates/ ssh/config.tpl" , Path : "ssh/config" , Comment : "#" },
20
+ {Name : "known_hosts.tpl" , Type : templates .File , TemplatePath : "templates/ ssh/known_hosts.tpl" , Path : "ssh/known_hosts" , Comment : "#" },
20
21
},
21
22
Host : []templates.Template {
22
- {Name : "sshd_config.tpl" , Type : templates .Snippet , TemplatePath : "ssh/sshd_config.tpl" , Path : "/etc/ssh/sshd_config" , Comment : "#" },
23
- {Name : "ca.tpl" , Type : templates .Snippet , TemplatePath : "ssh/ca.tpl" , Path : "/etc/ssh/ca.pub" , Comment : "#" },
23
+ {Name : "sshd_config.tpl" , Type : templates .Snippet , TemplatePath : "templates/ ssh/sshd_config.tpl" , Path : "/etc/ssh/sshd_config" , Comment : "#" },
24
+ {Name : "ca.tpl" , Type : templates .Snippet , TemplatePath : "templates/ ssh/ca.tpl" , Path : "/etc/ssh/ca.pub" , Comment : "#" },
24
25
},
25
26
}
26
27
@@ -36,7 +37,7 @@ var sshTemplateData = map[string]string{
36
37
ForwardAgent yes
37
38
UserKnownHostsFile {{.User.StepPath}}/config/ssh/known_hosts` ,
38
39
39
- // known_hosts.tpl authorizes the ssh hosst key
40
+ // known_hosts.tpl authorizes the ssh hosts key
40
41
"known_hosts.tpl" : "@cert-authority * {{.Step.SSH.HostKey.Type}} {{.Step.SSH.HostKey.Marshal | toString | b64enc}}" ,
41
42
42
43
// sshd_config.tpl adds the configuration to support certificates
@@ -82,7 +83,7 @@ func generateTemplates(t *templates.Templates) error {
82
83
if ! ok {
83
84
return errors .Errorf ("template %s does not exists" , t .Name )
84
85
}
85
- if err := utils .WriteFile (filepath . Join ( base , t .TemplatePath ), []byte (data ), 0644 ); err != nil {
86
+ if err := utils .WriteFile (config . StepAbs ( t .TemplatePath ), []byte (data ), 0644 ); err != nil {
86
87
return err
87
88
}
88
89
}
@@ -91,7 +92,7 @@ func generateTemplates(t *templates.Templates) error {
91
92
if ! ok {
92
93
return errors .Errorf ("template %s does not exists" , t .Name )
93
94
}
94
- if err := utils .WriteFile (filepath . Join ( base , t .TemplatePath ), []byte (data ), 0644 ); err != nil {
95
+ if err := utils .WriteFile (config . StepAbs ( t .TemplatePath ), []byte (data ), 0644 ); err != nil {
95
96
return err
96
97
}
97
98
}
0 commit comments