hcloud-upload-image/hcloudimages/internal/sshsession/session.go
Julian Tölle 06284185c8 feat: upload local disk images
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 18:15:31 +02: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)
}