func (c *Cmd) Start() error {
	var err error
	if c.client == nil {
		return fmt.Errorf("Cmd has no client")
	}
	if c.session, err = c.client.NewSession(); err != nil {
		return err
	}
	c.Env = append(c.Env, "CPUNONCE="+c.nonce.String())
	if err := c.SetEnv(c.Env...); err != nil {
		return err
	}
	if c.Stdin, err = c.session.StdinPipe(); err != nil {
		return err
	}
	if c.Stdout, err = c.session.StdoutPipe(); err != nil {
		return err
	}
	if c.Stderr, err = c.session.StderrPipe(); err != nil {
		return err
	}
	cmd := fmt.Sprintf("%s -port9p %v %q", c.cmd, c.port9p, strings.Join(c.Args, " "))
	V("call session.Start(%s)", cmd)
	if err := c.session.Start(cmd); err != nil {
		return fmt.Errorf("Failed to run %v: %v", c, err.Error())
	}
	return nil
}
Start implements exec.Start for CPU.
package cpu
import (
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
	"time"
	"golang.org/x/crypto/ssh"
)
const (
	defaultTimeOut = time.Duration(100 * time.Millisecond)
	defaultPort    = 23
)
var V = func(string, ...interface{}) {}
type Cmd struct {
	config  ssh.ClientConfig
	client  *ssh.Client
	session *ssh.Session
	Host           string
	Args           []string
	Root           string
	HostKeyFile    string
	PrivateKeyFile string
	Port           uint16
	Timeout        time.Duration
	Env            []string
	Stdin          io.WriteCloser
	Stdout         io.Reader
	Stderr         io.Reader
	nonce   nonce
	network string  
	port9p  uint16  
	cmd     string  
}
func Command(host string, args ...string) *Cmd {
	if len(args) == 0 {
		args = []string{os.Getenv("SHELL")}
	}
	return &Cmd{
		Host:    host,
		Args:    args,
		Port:    defaultPort,
		Timeout: defaultTimeOut,
		config: ssh.ClientConfig{
			User:            os.Getenv("USER"),
			HostKeyCallback: ssh.InsecureIgnoreHostKey(),
		},
		network: "tcp",
		Root: "",
		cmd: "cpud -remote -bin cpud",
	}
}
func (c *Cmd) WithPrivateKeyFile(key string) *Cmd {
	c.PrivateKeyFile = key
	return c
}
func (c *Cmd) WithHostKeyFile(key string) *Cmd {
	c.HostKeyFile = key
	return c
}
func (c *Cmd) WithPort(port uint16) *Cmd {
	c.Port = port
	return c
}
func (c *Cmd) WithRoot(root string) *Cmd {
	c.Root = root
	return c
}
func (c *Cmd) Dial() error {
	if err := c.UserKeyConfig(); err != nil {
		return err
	}
	addr := fmt.Sprintf("%s:%d", c.Host, c.Port)
	cl, err := ssh.Dial(c.network, addr, &c.config)
	V("cpu:ssh.Dial(%s, %s, %v): (%v, %v)", c.network, addr, c.config, cl, err)
	if err != nil {
		return fmt.Errorf("Failed to dial: %v", err)
	}
	c.client = cl
	if len(c.Root) == 0 {
		return nil
	}
	if _, ok := os.LookupEnv("CPU_NAMESPACE"); !ok {
		return fmt.Errorf("Root is set to %q but there is no CPU_NAMESPACE", c.Root)
	}
	l, err := cl.Listen("tcp", "127.0.0.1:0")
	if err != nil {
		return fmt.Errorf("cpu client listen for forwarded 9p port %v", err)
	}
	V("ssh.listener %v", l.Addr().String())
	ap := strings.Split(l.Addr().String(), ":")
	if len(ap) == 0 {
		return fmt.Errorf("Can't find a port number in %v", l.Addr().String())
	}
	port9p, err := strconv.ParseUint(ap[len(ap)-1], 0, 16)
	if err != nil {
		return fmt.Errorf("Can't find a 16-bit port number in %v", l.Addr().String())
	}
	c.port9p = uint16(port9p)
	V("listener %T %v addr %v port %v", l, l, l.Addr().String(), port9p)
	nonce, err := generateNonce()
	if err != nil {
		log.Fatalf("Getting nonce: %v", err)
	}
	c.Env = append(c.Env, "CPUNONCE="+nonce.String())
	c.nonce = nonce
	go c.srv(l)
	return nil
}