MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / SshRemoteRunCommand

Function SshRemoteRunCommand

cli/pkg/common/sshhelper.go:43–58  ·  view source on GitHub ↗
(sshClient *ssh.Client, command string)

Source from the content-addressed store, hash-verified

41}
42
43func SshRemoteRunCommand(sshClient *ssh.Client, command string) (string, error) {
44 session, err := sshClient.NewSession()
45 if err != nil {
46 return "", err
47 }
48 defer session.Close()
49 var buf bytes.Buffer
50 session.Stdout = &buf
51 err = session.Run(command)
52 logString := buf.String()
53 //logrus.WithField("CMD:", command).Info(logString)
54 if err != nil {
55 return logString, fmt.Errorf("CMD: %s OUT: %s ERROR: %s", command, logString, err)
56 }
57 return logString, err
58}
59func NewSshClientConfig(sshUser, sshPassword, sshType, sshKey, sshKeyPassword string) (config *ssh.ClientConfig, err error) {
60 if sshUser == "" {
61 return nil, errors.New("ssh_user can not be empty")

Callers

nothing calls this directly

Calls 2

RunMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected