summaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/ssh/client.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/ssh/client.go b/internal/ssh/client.go
index 1cd336c..b9c8d0f 100644
--- a/internal/ssh/client.go
+++ b/internal/ssh/client.go
@@ -132,6 +132,42 @@ func (c *Client) RunSudo(cmd string) (string, error) {
132 return c.Run("sudo " + cmd) 132 return c.Run("sudo " + cmd)
133} 133}
134 134
135// RunSudoStream executes a command with sudo and streams output to stdout/stderr
136func (c *Client) RunSudoStream(cmd string) error {
137 session, err := c.client.NewSession()
138 if err != nil {
139 return err
140 }
141 defer session.Close()
142
143 session.Stdout = os.Stdout
144 session.Stderr = os.Stderr
145
146 if err := session.Run("sudo " + cmd); err != nil {
147 return fmt.Errorf("command failed: %w", err)
148 }
149
150 return nil
151}
152
153// RunStream executes a command and streams output to stdout/stderr
154func (c *Client) RunStream(cmd string) error {
155 session, err := c.client.NewSession()
156 if err != nil {
157 return err
158 }
159 defer session.Close()
160
161 session.Stdout = os.Stdout
162 session.Stderr = os.Stderr
163
164 if err := session.Run(cmd); err != nil {
165 return fmt.Errorf("command failed: %w", err)
166 }
167
168 return nil
169}
170
135// Upload copies a local file to the remote host using scp 171// Upload copies a local file to the remote host using scp
136func (c *Client) Upload(localPath, remotePath string) error { 172func (c *Client) Upload(localPath, remotePath string) error {
137 // Use external scp command for simplicity 173 // Use external scp command for simplicity