@@ -132,7 +132,12 @@ func configSSH(configpath *string, remove *bool, next *bool) func(cmd *cobra.Com
132
132
}
133
133
}
134
134
135
- newConfig := makeNewConfigs (user .Username , envsWithProviders , 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 , envsWithProviders , privateKeyFilepath , p2p )
136
141
137
142
err = os .MkdirAll (filepath .Dir (* configpath ), os .ModePerm )
138
143
if err != nil {
@@ -193,7 +198,7 @@ func writeSSHKey(ctx context.Context, client coder.Client, privateKeyPath string
193
198
return ioutil .WriteFile (privateKeyPath , []byte (key .PrivateKey ), 0600 )
194
199
}
195
200
196
- func makeNewConfigs (userName string , envs []coderutil.EnvWithWorkspaceProvider , privateKeyFilepath string , p2p bool ) string {
201
+ func makeNewConfigs (binPath , userName string , envs []coderutil.EnvWithWorkspaceProvider , privateKeyFilepath string , p2p bool ) string {
197
202
newConfig := fmt .Sprintf ("\n %s\n %s\n \n " , sshStartToken , sshStartMessage )
198
203
199
204
sort .Slice (envs , func (i , j int ) bool { return envs [i ].Env .Name < envs [j ].Env .Name })
@@ -213,26 +218,24 @@ func makeNewConfigs(userName string, envs []coderutil.EnvWithWorkspaceProvider,
213
218
}
214
219
215
220
useTunnel := env .WorkspaceProvider .BuiltIn && p2p
216
- newConfig += makeSSHConfig (u .Host , userName , env .Env .Name , privateKeyFilepath , useTunnel )
221
+ newConfig += makeSSHConfig (binPath , u .Host , userName , env .Env .Name , privateKeyFilepath , useTunnel )
217
222
}
218
223
newConfig += fmt .Sprintf ("\n %s\n " , sshEndToken )
219
224
220
225
return newConfig
221
226
}
222
227
223
- func makeSSHConfig (host , userName , envName , privateKeyFilepath string , tunnel bool ) string {
228
+ func makeSSHConfig (binPath , host , userName , envName , privateKeyFilepath string , tunnel bool ) string {
224
229
if tunnel {
225
230
return fmt .Sprintf (
226
231
`Host coder.%s
227
232
HostName coder.%s
228
- ProxyCommand coder tunnel %s 12213 stdio
233
+ ProxyCommand %s tunnel %s 12213 stdio
229
234
StrictHostKeyChecking no
230
235
ConnectTimeout=0
231
236
IdentitiesOnly yes
232
237
IdentityFile="%s"
233
- ServerAliveInterval 60
234
- ServerAliveCountMax 3
235
- ` , envName , envName , envName , privateKeyFilepath )
238
+ ` , envName , envName , binPath , envName , privateKeyFilepath )
236
239
}
237
240
238
241
return fmt .Sprintf (
0 commit comments