|
|
@@ -21,11 +21,18 @@ type StepSSH struct {
|
|
|
// Relative paths are relative to the StepPath.
|
|
|
var DefaultSSHTemplates = SSHTemplates{
|
|
|
User: []Template{
|
|
|
+ {
|
|
|
+ Name: "base_config.tpl",
|
|
|
+ Type: Snippet,
|
|
|
+ TemplatePath: "templates/ssh/base_config.tpl",
|
|
|
+ Path: "~/.ssh/config",
|
|
|
+ Comment: "#",
|
|
|
+ },
|
|
|
{
|
|
|
Name: "include.tpl",
|
|
|
- Type: Fragment,
|
|
|
+ Type: Line,
|
|
|
TemplatePath: "templates/ssh/include.tpl",
|
|
|
- Path: "~/.ssh/config",
|
|
|
+ Path: "~/.ssh/include",
|
|
|
Comment: "#",
|
|
|
},
|
|
|
{
|
|
|
@@ -64,18 +71,28 @@ var DefaultSSHTemplates = SSHTemplates{
|
|
|
|
|
|
// DefaultSSHTemplateData contains the data of the default templates used on ssh.
|
|
|
var DefaultSSHTemplateData = map[string]string{
|
|
|
- // include.tpl adds the step ssh config file.
|
|
|
+ // base_config.tpl adds the step ssh config file.
|
|
|
//
|
|
|
// Note: on windows `Include C:\...` is treated as a relative path.
|
|
|
- "include.tpl": `{{- if .User.Authority }}# {{ .User.Authority }}
|
|
|
-{{ end }}# autogenerated by step
|
|
|
-# @ {{ now }}
|
|
|
-Host *
|
|
|
+ "base_config.tpl": `Host *
|
|
|
{{- if or .User.GOOS "none" | eq "windows" }}
|
|
|
+{{- if .User.Authority }}
|
|
|
+ Include "{{ .User.Home | replace "\\" "/" | trimPrefix "C:" }}/.ssh/include"
|
|
|
+{{- else }}
|
|
|
Include "{{ .User.StepPath | replace "\\" "/" | trimPrefix "C:" }}/ssh/config"
|
|
|
+{{- end }}
|
|
|
+{{- else }}
|
|
|
+{{- if .User.Authority }}
|
|
|
+ Include "{{.User.Home}}/.ssh/include"
|
|
|
{{- else }}
|
|
|
Include "{{.User.StepPath}}/ssh/config"
|
|
|
-{{ end }}# end`,
|
|
|
+{{- end }}
|
|
|
+{{- end }}`,
|
|
|
+
|
|
|
+ // include.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 }}`,
|
|
|
|
|
|
// config.tpl is the step ssh config file, it includes the Match rule and
|
|
|
// references the step known_hosts file.
|
|
|
@@ -87,10 +104,10 @@ Host *
|
|
|
{{- end }}
|
|
|
{{- if or .User.GOOS "none" | eq "windows" }}
|
|
|
UserKnownHostsFile "{{.User.StepPath}}\ssh\known_hosts"
|
|
|
- ProxyCommand C:\Windows\System32\cmd.exe /c step ssh proxycommand %r %h %p
|
|
|
+ ProxyCommand C:\Windows\System32\cmd.exe /c step ssh proxycommand{{- if .User.Context }} --context {{ .User.Context }}{{- end }} %r %h %p
|
|
|
{{- else }}
|
|
|
UserKnownHostsFile "{{.User.StepPath}}/ssh/known_hosts"
|
|
|
- ProxyCommand step ssh proxycommand %r %h %p
|
|
|
+ ProxyCommand step ssh proxycommand{{- if .User.Context }} --context {{ .User.Context }}{{- end }} %r %h %p
|
|
|
{{- end }}
|
|
|
`,
|
|
|
|