func (c *SSHClient) ExecuteBatch(commands []string, prependSudo bool) error {
	fmt.Printf("**** Host: %s ****\n", c.client.RemoteAddr().String())
	for _, cmd := range commands {
		fmt.Printf("** Execute command: %s **\n", cmd)
		stdout, stderr, err := c.ExecuteOne(cmd, prependSudo)
		if err != nil {
			return err
		}
		if len(stdout) > 0 {
			fmt.Println(stdout)
		}
		if len(stderr) > 0 {
			fmt.Printf("Error: %s\n", stderr)
		}
		fmt.Println()
	}
	return nil
}
ExecuteBatch execute bach commands
package client
import (
	"bytes"
	"fmt"
	"io/ioutil"
	"strings"
	"golang.org/x/crypto/ssh"
)
type SSHClient struct {
	config *ssh.ClientConfig
	client *ssh.Client
}
func NewSSHClientConfig(user, keyFile, passworkPhrase string) (*SSHClient, error) {
	publicKeyMenthod, err := publicKey(keyFile, passworkPhrase)
	if err != nil {
		return nil, err
	}
	sshConfig := &ssh.ClientConfig{
		User: user,
		Auth: []ssh.AuthMethod{
			publicKeyMenthod,
		},
		HostKeyCallback: ssh.InsecureIgnoreHostKey(),
	}
	return &SSHClient{
		config: sshConfig,
	}, nil
}
func (c *SSHClient) Connect(host, port string) error {
	client, err := ssh.Dial("tcp", fmt.Sprintf("%s:%s", host, port), c.config)
	if err != nil {
		return err
	}
	c.client = client
	return nil
}
func (c *SSHClient) Close() error {
	if c.client != nil {
		return c.client.Close()
	}
	return nil
}