mirror of
https://github.com/apricote/hcloud-upload-image.git
synced 2026-01-13 21:31:03 +00:00
21 lines
331 B
Go
21 lines
331 B
Go
package sshsession
|
|
|
|
import (
|
|
"io"
|
|
|
|
"golang.org/x/crypto/ssh"
|
|
)
|
|
|
|
func Run(client *ssh.Client, cmd string, stdin io.Reader) ([]byte, error) {
|
|
sess, err := client.NewSession()
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer func() { _ = sess.Close() }()
|
|
|
|
if stdin != nil {
|
|
sess.Stdin = stdin
|
|
}
|
|
return sess.CombinedOutput(cmd)
|
|
}
|