@@ -132,7 +132,12 @@ func configSSH(configpath *string, remove *bool, next *bool) func(cmd *cobra.Com
132132 }
133133 }
134134
135- newConfig := makeNewConfigs (user .Username , workspacesWithProviders , privateKeyFilepath , p2p )
135+ binPath , err := os .Executable ()
136+ if err != nil {
137+ return xerrors .Errorf ("Failed to get executable path: %w" , err )
138+ }
139+
140+ newConfig := makeNewConfigs (binPath , user .Username , workspacesWithProviders , privateKeyFilepath , p2p )
136141
137142 err = os .MkdirAll (filepath .Dir (* configpath ), os .ModePerm )
138143 if err != nil {
@@ -193,7 +198,7 @@ func writeSSHKey(ctx context.Context, client coder.Client, privateKeyPath string
193198 return ioutil .WriteFile (privateKeyPath , []byte (key .PrivateKey ), 0600 )
194199}
195200
196- func makeNewConfigs (userName string , workspaces []coderutil.WorkspaceWithWorkspaceProvider , privateKeyFilepath string , p2p bool ) string {
201+ func makeNewConfigs (binPath , userName string , workspaces []coderutil.WorkspaceWithWorkspaceProvider , privateKeyFilepath string , p2p bool ) string {
197202 newConfig := fmt .Sprintf ("\n %s\n %s\n \n " , sshStartToken , sshStartMessage )
198203
199204 sort .Slice (workspaces , func (i , j int ) bool { return workspaces [i ].Workspace .Name < workspaces [j ].Workspace .Name })
@@ -213,24 +218,24 @@ func makeNewConfigs(userName string, workspaces []coderutil.WorkspaceWithWorkspa
213218 }
214219
215220 useTunnel := workspace .WorkspaceProvider .BuiltIn && p2p
216- newConfig += makeSSHConfig (u .Host , userName , workspace .Workspace .Name , privateKeyFilepath , useTunnel )
221+ newConfig += makeSSHConfig (binPath , u .Host , userName , workspace .Workspace .Name , privateKeyFilepath , useTunnel )
217222 }
218223 newConfig += fmt .Sprintf ("\n %s\n " , sshEndToken )
219224
220225 return newConfig
221226}
222227
223- func makeSSHConfig (host , userName , workspaceName , privateKeyFilepath string , tunnel bool ) string {
228+ func makeSSHConfig (binPath , host , userName , workspaceName , privateKeyFilepath string , tunnel bool ) string {
224229 if tunnel {
225230 return fmt .Sprintf (
226231 `Host coder.%s
227232 HostName coder.%s
228- ProxyCommand coder tunnel %s 12213 stdio
233+ ProxyCommand %s tunnel %s 12213 stdio
229234 StrictHostKeyChecking no
230235 ConnectTimeout=0
231236 IdentitiesOnly yes
232237 IdentityFile="%s"
233- ` , workspaceName , workspaceName , workspaceName , privateKeyFilepath )
238+ ` , workspaceName , workspaceName , binPath , workspaceName , privateKeyFilepath )
234239 }
235240
236241 return fmt .Sprintf (
0 commit comments