@@ -35,23 +35,21 @@ func configSSHCmd() *cobra.Command {
35
35
var (
36
36
configpath string
37
37
remove = false
38
- next = false
39
38
)
40
39
41
40
cmd := & cobra.Command {
42
41
Use : "config-ssh" ,
43
42
Short : "Configure SSH to access Coder workspaces" ,
44
43
Long : "Inject the proper OpenSSH configuration into your local SSH config file." ,
45
- RunE : configSSH (& configpath , & remove , & next ),
44
+ RunE : configSSH (& configpath , & remove ),
46
45
}
47
46
cmd .Flags ().StringVar (& configpath , "filepath" , filepath .Join ("~" , ".ssh" , "config" ), "override the default path of your ssh config file" )
48
47
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" )
50
48
51
49
return cmd
52
50
}
53
51
54
- func configSSH (configpath * string , remove * bool , next * bool ) func (cmd * cobra.Command , _ []string ) error {
52
+ func configSSH (configpath * string , remove * bool ) func (cmd * cobra.Command , _ []string ) error {
55
53
return func (cmd * cobra.Command , _ []string ) error {
56
54
ctx := cmd .Context ()
57
55
usr , err := user .Current ()
@@ -115,29 +113,12 @@ func configSSH(configpath *string, remove *bool, next *bool) func(cmd *cobra.Com
115
113
return xerrors .New ("SSH is disabled or not available for any workspaces in your Coder deployment." )
116
114
}
117
115
118
- wconf , err := client .SiteConfigWorkspaces (ctx )
119
- if err != nil {
120
- return xerrors .Errorf ("getting site workspace config: %w" , err )
121
- }
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
- }
134
-
135
116
binPath , err := os .Executable ()
136
117
if err != nil {
137
118
return xerrors .Errorf ("Failed to get executable path: %w" , err )
138
119
}
139
120
140
- newConfig := makeNewConfigs (binPath , user .Username , workspacesWithProviders , privateKeyFilepath , p2p )
121
+ newConfig := makeNewConfigs (binPath , user .Username , workspacesWithProviders , privateKeyFilepath )
141
122
142
123
err = os .MkdirAll (filepath .Dir (* configpath ), os .ModePerm )
143
124
if err != nil {
@@ -198,7 +179,7 @@ func writeSSHKey(ctx context.Context, client coder.Client, privateKeyPath string
198
179
return ioutil .WriteFile (privateKeyPath , []byte (key .PrivateKey ), 0600 )
199
180
}
200
181
201
- func makeNewConfigs (binPath , userName string , workspaces []coderutil.WorkspaceWithWorkspaceProvider , privateKeyFilepath string , p2p bool ) string {
182
+ func makeNewConfigs (binPath , userName string , workspaces []coderutil.WorkspaceWithWorkspaceProvider , privateKeyFilepath string ) string {
202
183
newConfig := fmt .Sprintf ("\n %s\n %s\n \n " , sshStartToken , sshStartMessage )
203
184
204
185
sort .Slice (workspaces , func (i , j int ) bool { return workspaces [i ].Workspace .Name < workspaces [j ].Workspace .Name })
@@ -217,7 +198,7 @@ func makeNewConfigs(binPath, userName string, workspaces []coderutil.WorkspaceWi
217
198
continue
218
199
}
219
200
220
- useTunnel := workspace .WorkspaceProvider .BuiltIn && p2p
201
+ useTunnel := workspace .WorkspaceProvider .SSHEnabled && workspace . WorkspaceProvider . EnableNetV2
221
202
newConfig += makeSSHConfig (binPath , u .Host , userName , workspace .Workspace .Name , privateKeyFilepath , useTunnel )
222
203
}
223
204
newConfig += fmt .Sprintf ("\n %s\n " , sshEndToken )
0 commit comments