@@ -45,8 +45,10 @@ const (
4545// sshConfigOptions represents options that can be stored and read
4646// from the coder config in ~/.ssh/coder.
4747type sshConfigOptions struct {
48- waitEnum string
48+ waitEnum string
49+ // Deprecated: moving away from prefix to hostnameSuffix
4950 userHostPrefix string
51+ hostnameSuffix string
5052 sshOptions []string
5153 disableAutostart bool
5254 header []string
@@ -97,7 +99,11 @@ func (o sshConfigOptions) equal(other sshConfigOptions) bool {
9799 if ! slicesSortedEqual (o .header , other .header ) {
98100 return false
99101 }
100- return o .waitEnum == other .waitEnum && o .userHostPrefix == other .userHostPrefix && o .disableAutostart == other .disableAutostart && o .headerCommand == other .headerCommand
102+ return o .waitEnum == other .waitEnum &&
103+ o .userHostPrefix == other .userHostPrefix &&
104+ o .disableAutostart == other .disableAutostart &&
105+ o .headerCommand == other .headerCommand &&
106+ o .hostnameSuffix == other .hostnameSuffix
101107}
102108
103109// slicesSortedEqual compares two slices without side-effects or regard to order.
@@ -119,6 +125,9 @@ func (o sshConfigOptions) asList() (list []string) {
119125 if o .userHostPrefix != "" {
120126 list = append (list , fmt .Sprintf ("ssh-host-prefix: %s" , o .userHostPrefix ))
121127 }
128+ if o .hostnameSuffix != "" {
129+ list = append (list , fmt .Sprintf ("hostname-suffix: %s" , o .hostnameSuffix ))
130+ }
122131 if o .disableAutostart {
123132 list = append (list , fmt .Sprintf ("disable-autostart: %v" , o .disableAutostart ))
124133 }
@@ -314,6 +323,10 @@ func (r *RootCmd) configSSH() *serpent.Command {
314323 // Override with user flag.
315324 coderdConfig .HostnamePrefix = sshConfigOpts .userHostPrefix
316325 }
326+ if sshConfigOpts .hostnameSuffix != "" {
327+ // Override with user flag.
328+ coderdConfig .HostnameSuffix = sshConfigOpts .hostnameSuffix
329+ }
317330
318331 // Write agent configuration.
319332 defaultOptions := []string {
@@ -518,6 +531,12 @@ func (r *RootCmd) configSSH() *serpent.Command {
518531 Description : "Override the default host prefix." ,
519532 Value : serpent .StringOf (& sshConfigOpts .userHostPrefix ),
520533 },
534+ {
535+ Flag : "hostname-suffix" ,
536+ Env : "CODER_CONFIGSSH_HOSTNAME_SUFFIX" ,
537+ Description : "Override the default hostname suffix." ,
538+ Value : serpent .StringOf (& sshConfigOpts .hostnameSuffix ),
539+ },
521540 {
522541 Flag : "wait" ,
523542 Env : "CODER_CONFIGSSH_WAIT" , // Not to be mixed with CODER_SSH_WAIT.
@@ -568,6 +587,9 @@ func sshConfigWriteSectionHeader(w io.Writer, addNewline bool, o sshConfigOption
568587 if o .userHostPrefix != "" {
569588 _ , _ = fmt .Fprintf (& ow , "# :%s=%s\n " , "ssh-host-prefix" , o .userHostPrefix )
570589 }
590+ if o .hostnameSuffix != "" {
591+ _ , _ = fmt .Fprintf (& ow , "# :%s=%s\n " , "hostname-suffix" , o .hostnameSuffix )
592+ }
571593 if o .disableAutostart {
572594 _ , _ = fmt .Fprintf (& ow , "# :%s=%v\n " , "disable-autostart" , o .disableAutostart )
573595 }
@@ -607,6 +629,8 @@ func sshConfigParseLastOptions(r io.Reader) (o sshConfigOptions) {
607629 o .waitEnum = parts [1 ]
608630 case "ssh-host-prefix" :
609631 o .userHostPrefix = parts [1 ]
632+ case "hostname-suffix" :
633+ o .hostnameSuffix = parts [1 ]
610634 case "ssh-option" :
611635 o .sshOptions = append (o .sshOptions , parts [1 ])
612636 case "disable-autostart" :
0 commit comments