Files
ssh-netbox-wrapper/internal/ssh/exec.go
T
Sebastian Unterschütz 8d4915543e
Test / test (push) Successful in 3m36s
Release / release (push) Successful in 7m31s
v1
2026-11-17 19:00:44 +01:00

23 lines
587 B
Go

package ssh
import (
"fmt"
"os"
"os/exec"
"syscall"
)
// Exec replaces the current process with the native ssh client via syscall.Exec.
// All existing SSH configs, keys, and agent forwarding remain intact.
func Exec(args []string) error { return SSH.Exec(args) }
// Exec replaces the current process with the client's binary.
func (c Client) Exec(args []string) error {
path, err := exec.LookPath(c.Name)
if err != nil {
return fmt.Errorf("%s not found in PATH: %w", c.Name, err)
}
argv := append([]string{c.Name}, args...)
return syscall.Exec(path, argv, os.Environ())
}