示例#1
0
func getSSHCommand(m driver.Machine, args ...string) *exec.Cmd {

	DefaultSSHArgs := []string{
		"-o", "IdentitiesOnly=yes",
		"-o", "StrictHostKeyChecking=no",
		"-o", "UserKnownHostsFile=/dev/null",
		"-o", "LogLevel=quiet", // suppress "Warning: Permanently added '[localhost]:2022' (ECDSA) to the list of known hosts."
		"-p", fmt.Sprintf("%d", m.GetSSHPort()),
		"-i", B2D.SSHKey,
		"docker@localhost",
	}

	sshArgs := append(DefaultSSHArgs, args...)
	cmd := exec.Command(B2D.SSH, sshArgs...)
	if B2D.Verbose {
		cmd.Stderr = os.Stderr
		log.Printf("executing: %v %v", cmd.Path, strings.Join(cmd.Args, " "))
	}

	return cmd
}