@@ -125,7 +125,7 @@ var sshInfo struct {
125
125
//
126
126
// The result always contains the IdentityFile option.
127
127
// The result never contains the Port option.
128
- func CommonOpts (useDotSSH bool ) ([]string , error ) {
128
+ func CommonOpts (useDotSSH bool , localhost bool ) ([]string , error ) {
129
129
configDir , err := dirnames .LimaConfigDir ()
130
130
if err != nil {
131
131
return nil , err
@@ -180,14 +180,20 @@ func CommonOpts(useDotSSH bool) ([]string, error) {
180
180
}
181
181
}
182
182
183
+ if localhost {
184
+ opts = append (opts ,
185
+ "StrictHostKeyChecking=no" ,
186
+ "UserKnownHostsFile=/dev/null" ,
187
+ "BatchMode=yes" ,
188
+ )
189
+ }
190
+
183
191
opts = append (opts ,
184
- "StrictHostKeyChecking=no" ,
185
- "UserKnownHostsFile=/dev/null" ,
186
192
"NoHostAuthenticationForLocalhost=yes" ,
187
193
"GSSAPIAuthentication=no" ,
188
194
"PreferredAuthentications=publickey" ,
189
195
"Compression=no" ,
190
- "BatchMode=yes " ,
196
+ "PasswordAuthentication=no " ,
191
197
"IdentitiesOnly=yes" ,
192
198
)
193
199
@@ -222,7 +228,7 @@ func CommonOpts(useDotSSH bool) ([]string, error) {
222
228
}
223
229
224
230
// SSHOpts adds the following options to CommonOptions: User, ControlMaster, ControlPath, ControlPersist
225
- func SSHOpts (instDir string , useDotSSH , forwardAgent bool , forwardX11 bool , forwardX11Trusted bool ) ([]string , error ) {
231
+ func SSHOpts (instDir string , useDotSSH bool , hostAddress string , forwardAgent bool , forwardX11 bool , forwardX11Trusted bool ) ([]string , error ) {
226
232
controlSock := filepath .Join (instDir , filenames .SSHSock )
227
233
if len (controlSock ) >= osutil .UnixPathMax {
228
234
return nil , fmt .Errorf ("socket path %q is too long: >= UNIX_PATH_MAX=%d" , controlSock , osutil .UnixPathMax )
@@ -231,7 +237,7 @@ func SSHOpts(instDir string, useDotSSH, forwardAgent bool, forwardX11 bool, forw
231
237
if err != nil {
232
238
return nil , err
233
239
}
234
- opts , err := CommonOpts (useDotSSH )
240
+ opts , err := CommonOpts (useDotSSH , hostAddress == "127.0.0.1" )
235
241
if err != nil {
236
242
return nil , err
237
243
}
0 commit comments