Files
ssh-netbox-wrapper/internal/ssh/exec.go
T

20 lines
452 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 {
sshPath, err := exec.LookPath("ssh")
if err != nil {
return fmt.Errorf("ssh not found in PATH: %w", err)
}
argv := append([]string{"ssh"}, args...)
return syscall.Exec(sshPath, argv, os.Environ())
}