func combined(c *ssh.Client, cmd string) ([]byte, error) { s, err := c.NewSession() if err != nil { return nil, err } defer s.Close() return s.CombinedOutput(cmd) }
func copyFile(c *ssh.Client, r io.Reader, path string) error { s, err := c.NewSession() if err != nil { return err } defer s.Close() w, err := s.StdinPipe() if err != nil { return err } s.Start("tee " + path) _, err = io.Copy(w, r) if err != nil { return err } w.Close() return s.Wait() }