@@ -35,23 +35,21 @@ func configSSHCmd() *cobra.Command {
3535 var (
3636 configpath string
3737 remove = false
38- p2p = false
3938 )
4039
4140 cmd := & cobra.Command {
4241 Use : "config-ssh" ,
4342 Short : "Configure SSH to access Coder environments" ,
4443 Long : "Inject the proper OpenSSH configuration into your local SSH config file." ,
45- RunE : configSSH (& configpath , & remove , & p2p ),
44+ RunE : configSSH (& configpath , & remove ),
4645 }
4746 cmd .Flags ().StringVar (& configpath , "filepath" , filepath .Join ("~" , ".ssh" , "config" ), "override the default path of your ssh config file" )
4847 cmd .Flags ().BoolVar (& remove , "remove" , false , "remove the auto-generated Coder ssh config" )
49- cmd .Flags ().BoolVar (& p2p , "p2p" , false , "(experimental) uses coder tunnel to proxy ssh connection" )
5048
5149 return cmd
5250}
5351
54- func configSSH (configpath * string , remove * bool , p2p * bool ) func (cmd * cobra.Command , _ []string ) error {
52+ func configSSH (configpath * string , remove * bool ) func (cmd * cobra.Command , _ []string ) error {
5553 return func (cmd * cobra.Command , _ []string ) error {
5654 ctx := cmd .Context ()
5755 usr , err := user .Current ()
@@ -115,7 +113,12 @@ func configSSH(configpath *string, remove *bool, p2p *bool) func(cmd *cobra.Comm
115113 return xerrors .New ("SSH is disabled or not available for any environments in your Coder deployment." )
116114 }
117115
118- newConfig := makeNewConfigs (user .Username , envsWithProviders , privateKeyFilepath , * p2p )
116+ wconf , err := client .SiteConfigWorkspaces (ctx )
117+ if err != nil {
118+ return xerrors .Errorf ("getting site workspace config: %w" , err )
119+ }
120+
121+ newConfig := makeNewConfigs (user .Username , envsWithProviders , privateKeyFilepath , wconf .EnableP2P )
119122
120123 err = os .MkdirAll (filepath .Dir (* configpath ), os .ModePerm )
121124 if err != nil {
@@ -194,15 +197,17 @@ func makeNewConfigs(userName string, envs []coderutil.EnvWithWorkspaceProvider,
194197 clog .LogWarn ("invalid access url" , clog .Causef ("malformed url: %q" , env .WorkspaceProvider .EnvproxyAccessURL ))
195198 continue
196199 }
197- newConfig += makeSSHConfig (u .Host , userName , env .Env .Name , privateKeyFilepath , p2p )
200+
201+ useTunnel := env .WorkspaceProvider .BuiltIn && p2p
202+ newConfig += makeSSHConfig (u .Host , userName , env .Env .Name , privateKeyFilepath , useTunnel )
198203 }
199204 newConfig += fmt .Sprintf ("\n %s\n " , sshEndToken )
200205
201206 return newConfig
202207}
203208
204- func makeSSHConfig (host , userName , envName , privateKeyFilepath string , p2p bool ) string {
205- if p2p {
209+ func makeSSHConfig (host , userName , envName , privateKeyFilepath string , tunnel bool ) string {
210+ if tunnel {
206211 return fmt .Sprintf (
207212 `Host coder.%s
208213 HostName coder.%s
0 commit comments