示例#1
0
func (s *storageSuite) sshCommand(c *gc.C, host string, command ...string) *ssh.Cmd {
	script := []byte("#!/bin/bash\n" + strings.Join(command, " "))
	err := ioutil.WriteFile(filepath.Join(s.bin, "ssh"), script, 0755)
	c.Assert(err, gc.IsNil)
	client, err := ssh.NewOpenSSHClient()
	c.Assert(err, gc.IsNil)
	return client.Command(host, command, nil)
}
示例#2
0
文件: ssh_test.go 项目: jameinel/core
func (s *SSHCommandSuite) SetUpTest(c *gc.C) {
	s.LoggingSuite.SetUpTest(c)
	s.testbin = c.MkDir()
	s.fakessh = filepath.Join(s.testbin, "ssh")
	s.fakescp = filepath.Join(s.testbin, "scp")
	err := ioutil.WriteFile(s.fakessh, []byte(echoCommandScript), 0755)
	c.Assert(err, gc.IsNil)
	err = ioutil.WriteFile(s.fakescp, []byte(echoCommandScript), 0755)
	c.Assert(err, gc.IsNil)
	s.PatchEnvPathPrepend(s.testbin)
	s.client, err = ssh.NewOpenSSHClient()
	c.Assert(err, gc.IsNil)
	s.PatchValue(ssh.DefaultIdentities, nil)
}