@@ -35,21 +35,23 @@ func configSSHCmd() *cobra.Command {
3535 var (
3636 configpath string
3737 remove = false
38+ next = false
3839 )
3940
4041 cmd := & cobra.Command {
4142 Use : "config-ssh" ,
4243 Short : "Configure SSH to access Coder environments" ,
4344 Long : "Inject the proper OpenSSH configuration into your local SSH config file." ,
44- RunE : configSSH (& configpath , & remove ),
45+ RunE : configSSH (& configpath , & remove , & next ),
4546 }
4647 cmd .Flags ().StringVar (& configpath , "filepath" , filepath .Join ("~" , ".ssh" , "config" ), "override the default path of your ssh config file" )
4748 cmd .Flags ().BoolVar (& remove , "remove" , false , "remove the auto-generated Coder ssh config" )
49+ cmd .Flags ().BoolVar (& next , "next" , false , "(alpha) uses coder tunnel to proxy ssh connection" )
4850
4951 return cmd
5052}
5153
52- func configSSH (configpath * string , remove * bool ) func (cmd * cobra.Command , _ []string ) error {
54+ func configSSH (configpath * string , remove * bool , next * bool ) func (cmd * cobra.Command , _ []string ) error {
5355 return func (cmd * cobra.Command , _ []string ) error {
5456 ctx := cmd .Context ()
5557 usr , err := user .Current ()
@@ -117,8 +119,20 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st
117119 if err != nil {
118120 return xerrors .Errorf ("getting site workspace config: %w" , err )
119121 }
122+ p2p := false
123+ if wconf .EnableP2P {
124+ if * next {
125+ p2p = true
126+ } else {
127+ fmt .Println ("Note: NetworkingV2 is enabled on the coder deployment, use --next to enable it for ssh" )
128+ }
129+ } else {
130+ if * next {
131+ return xerrors .New ("NetworkingV2 feature is not enabled, cannot use --next flag" )
132+ }
133+ }
120134
121- newConfig := makeNewConfigs (user .Username , envsWithProviders , privateKeyFilepath , wconf . EnableP2P )
135+ newConfig := makeNewConfigs (user .Username , envsWithProviders , privateKeyFilepath , p2p )
122136
123137 err = os .MkdirAll (filepath .Dir (* configpath ), os .ModePerm )
124138 if err != nil {
0 commit comments