hcloud-upload-image/hcloudimages/internal/sshsession/session.go
Julian Tölle fcea3e3c6e
feat: upload local disk images (#15)
The new options/flag enables users to use a local file as the image,
instead of a publicly available file from a web server.
2024-05-09 16:16:37 +00:00

21 lines
314 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 sess.Close()
if stdin != nil {
sess.Stdin = stdin
}
return sess.CombinedOutput(cmd)
}