@@ -251,13 +251,23 @@ func applyMain(cmd *cobra.Command, opts *cmdOpts.ApplyOpts) error {
251251
252252 if opts .TargetHost != "" {
253253 log .Debugf ("connecting to %s" , opts .TargetHost )
254- host , err := system .NewSSHSystem (localSystem , opts .TargetHost , log , cfg )
254+
255+ sshCfg , err := system .NewSSHConfig (opts .TargetHost , log , system.SSHConfigOptions {
256+ KnownHostsFiles : cfg .SSH .KnownHostsFiles ,
257+ PrivateKeyCmd : cfg .SSH .PrivateKeyCmd ,
258+ })
255259 if err != nil {
256260 log .Errorf ("%v" , err )
257261 return err
258262 }
259263
264+ host , err := system .NewSSHSystem (sshCfg , log )
265+ if err != nil {
266+ log .Errorf ("%v" , err )
267+ return err
268+ }
260269 defer host .Close ()
270+
261271 targetHost = host
262272 } else {
263273 targetHost = localSystem
@@ -313,13 +323,23 @@ func applyMain(cmd *cobra.Command, opts *cmdOpts.ApplyOpts) error {
313323
314324 if opts .BuildHost != "" {
315325 log .Debugf ("connecting to %s" , opts .BuildHost )
316- host , err := system .NewSSHSystem (localSystem , opts .BuildHost , log , cfg )
326+
327+ sshCfg , err := system .NewSSHConfig (opts .BuildHost , log , system.SSHConfigOptions {
328+ KnownHostsFiles : cfg .SSH .KnownHostsFiles ,
329+ PrivateKeyCmd : cfg .SSH .PrivateKeyCmd ,
330+ })
317331 if err != nil {
318332 log .Errorf ("%v" , err )
319333 return err
320334 }
321335
336+ host , err := system .NewSSHSystem (sshCfg , log )
337+ if err != nil {
338+ log .Errorf ("%v" , err )
339+ return err
340+ }
322341 defer host .Close ()
342+
323343 buildHost = host
324344 } else {
325345 buildHost = localSystem
0 commit comments