diff --git a/templates/templates.go b/templates/templates.go index ab0f1040..3a708731 100644 --- a/templates/templates.go +++ b/templates/templates.go @@ -249,6 +249,9 @@ type Output struct { // Write writes the Output to the filesystem as a directory, file or snippet. func (o *Output) Write() error { + // Replace ${STEPPATH} with the base step path. + o.Path = strings.Replace(o.Path, "${STEPPATH}", step.BasePath(), -1) + path := step.Abs(o.Path) if o.Type == Directory { return mkdir(path, 0700) diff --git a/templates/values.go b/templates/values.go index 60c0ad8f..c59843af 100644 --- a/templates/values.go +++ b/templates/values.go @@ -29,10 +29,10 @@ var DefaultSSHTemplates = SSHTemplates{ Comment: "#", }, { - Name: "include.tpl", + Name: "includes.tpl", Type: Line, - TemplatePath: "templates/ssh/include.tpl", - Path: "~/.ssh/include", + TemplatePath: "templates/ssh/includes.tpl", + Path: "${STEPPATH}/ssh/includes", Comment: "#", }, { @@ -77,22 +77,22 @@ var DefaultSSHTemplateData = map[string]string{ "base_config.tpl": `Host * {{- if or .User.GOOS "none" | eq "windows" }} {{- if .User.Authority }} - Include "{{ .User.Home | replace "\\" "/" | trimPrefix "C:" }}/.ssh/include" + Include "{{ .User.StepBasePath | replace "\\" "/" | trimPrefix "C:" }}/ssh/includes" {{- else }} Include "{{ .User.StepPath | replace "\\" "/" | trimPrefix "C:" }}/ssh/config" {{- end }} {{- else }} {{- if .User.Authority }} - Include "{{.User.Home}}/.ssh/include" + Include "{{.User.StepBasePath}}/ssh/includes" {{- else }} Include "{{.User.StepPath}}/ssh/config" {{- end }} {{- end }}`, - // include.tpl adds the step ssh config file. + // includes.tpl adds the step ssh config file. // // Note: on windows `Include C:\...` is treated as a relative path. - "include.tpl": `{{- if or .User.GOOS "none" | eq "windows" }}Include "{{ .User.StepPath | replace "\\" "/" | trimPrefix "C:" }}/ssh/config"{{- else }}Include "{{.User.StepPath}}/ssh/config"{{- end }}`, + "includes.tpl": `{{- if or .User.GOOS "none" | eq "windows" }}Include "{{ .User.StepPath | replace "\\" "/" | trimPrefix "C:" }}/ssh/config"{{- else }}Include "{{.User.StepPath}}/ssh/config"{{- end }}`, // config.tpl is the step ssh config file, it includes the Match rule and // references the step known_hosts file.