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