Skip to content

Commit

Permalink
Fix ssh-config short-lived-cert for subpath-ed hostnames
Browse files Browse the repository at this point in the history
  • Loading branch information
jeslinmx authored Apr 4, 2023
1 parent 39ed5dc commit 653bf87
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/cloudflared/access/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Add to your {{.Home}}/.ssh/config:
{{- if .ShortLivedCerts}}
Match host {{.Hostname}} exec "{{.Cloudflared}} access ssh-gen --hostname %h"
ProxyCommand {{.Cloudflared}} access ssh --hostname %h
IdentityFile ~/.cloudflared/%h-cf_key
CertificateFile ~/.cloudflared/%h-cf_key-cert.pub
IdentityFile ~/.cloudflared/{{.SSHCertFilePath}}-cf_key
CertificateFile ~/.cloudflared/{{.SSHCertFilePath}}-cf_key-cert.pub
{{- else}}
Host {{.Hostname}}
ProxyCommand {{.Cloudflared}} access ssh --hostname %h
Expand Down Expand Up @@ -365,10 +365,11 @@ func sshConfig(c *cli.Context) error {
ShortLivedCerts bool
Hostname string
Cloudflared string
SSHCertFilePath string
}

t := template.Must(template.New("sshConfig").Parse(sshConfigTemplate))
return t.Execute(os.Stdout, config{Home: os.Getenv("HOME"), ShortLivedCerts: genCertBool, Hostname: hostname, Cloudflared: cloudflaredPath()})
return t.Execute(os.Stdout, config{Home: os.Getenv("HOME"), ShortLivedCerts: genCertBool, Hostname: hostname, Cloudflared: cloudflaredPath(), SSHCertFilePath: token.GenerateSSHCertFilePathFromURL(url.Parse(ensureURLScheme(hostname)), sshgen.keyName)})
}

// sshGen generates a short lived certificate for provided hostname
Expand Down

0 comments on commit 653bf87

Please sign in to comment.