@@ -665,11 +665,11 @@ func IsTimeoutError(err error) bool {
665
665
return strings .Contains (err .Error (), ErrTimeout .Error ())
666
666
}
667
667
668
- func (c * sshClient ) getSSHClient () (* ssh.Client , * ssh. ClientConfig , error ) {
668
+ func (c * sshClient ) getSSHClient () (* ssh.Client , error ) {
669
669
// Create the Signer for this private key.
670
670
signer , err := ssh .ParsePrivateKey ([]byte (c .privateSSHKey ))
671
671
if err != nil {
672
- return nil , nil , fmt .Errorf ("unable to parse private key: %w" , err )
672
+ return nil , fmt .Errorf ("unable to parse private key: %w" , err )
673
673
}
674
674
675
675
config := & ssh.ClientConfig {
@@ -685,14 +685,14 @@ func (c *sshClient) getSSHClient() (*ssh.Client, *ssh.ClientConfig, error) {
685
685
// Connect to the remote server and perform the SSH handshake.
686
686
client , err := ssh .Dial ("tcp" , fmt .Sprintf ("%s:%v" , c .ip , c .port ), config )
687
687
if err != nil {
688
- return nil , nil , fmt .Errorf ("failed to dial ssh. Error message: %s. DialErr: %w" , err .Error (), errSSHDialFailed )
688
+ return nil , fmt .Errorf ("failed to dial ssh. Error message: %s. DialErr: %w" , err .Error (), errSSHDialFailed )
689
689
}
690
690
691
- return client , config , nil
691
+ return client , nil
692
692
}
693
693
694
694
func (c * sshClient ) runSSH (command string ) Output {
695
- client , _ , err := c .getSSHClient ()
695
+ client , err := c .getSSHClient ()
696
696
if err != nil {
697
697
return Output {Err : err }
698
698
}
@@ -767,7 +767,7 @@ func removeUselessLinesFromCloudInitOutput(s string) string {
767
767
}
768
768
769
769
func (c * sshClient ) ExecutePreProvisionCommand (ctx context.Context , command string ) (int , string , error ) {
770
- client , clientConfig , err := c .getSSHClient ()
770
+ client , err := c .getSSHClient ()
771
771
if err != nil {
772
772
return 0 , "" , err
773
773
}
@@ -780,14 +780,6 @@ func (c *sshClient) ExecutePreProvisionCommand(ctx context.Context, command stri
780
780
781
781
defer scpClient .Close ()
782
782
783
- scpClient .ClientConfig = clientConfig
784
- scpClient .Host = fmt .Sprintf ("%s:%d" , c .ip , c .port )
785
-
786
- err = scpClient .Connect ()
787
- if err != nil {
788
- return 0 , "" , fmt .Errorf ("couldn't establish a connection to the remote server: %w " , err )
789
- }
790
-
791
783
f , err := os .Open (command ) //nolint:gosec // the variable was valided.
792
784
if err != nil {
793
785
return 0 , "" , fmt .Errorf ("error opening file %q: %w" , command , err )
0 commit comments