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.
This commit is contained in:
Julian Tölle 2024-05-08 23:36:33 +02:00
parent 2eea318379
commit 06284185c8
3 changed files with 63 additions and 24 deletions

View file

@ -1,12 +1,21 @@
package sshsession
import "golang.org/x/crypto/ssh"
import (
"io"
func Run(client *ssh.Client, cmd string) ([]byte, error) {
"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)
}