mirror of
https://github.com/wahyd4/kt-connect.git
synced 2026-08-09 05:16:02 +10:00
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package ssh
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
)
|
|
|
|
// Version check sshuttle version
|
|
func Version() *exec.Cmd {
|
|
return exec.Command("ssh", "-V")
|
|
}
|
|
|
|
// ForwardRemoteRequestToLocal ssh remote port forward
|
|
func ForwardRemoteRequestToLocal(localPort, remoteHost, remotePort, privateKeyPath string, remoteSSHPort int) *exec.Cmd {
|
|
return exec.Command("ssh",
|
|
"-oStrictHostKeyChecking=no",
|
|
"-oUserKnownHostsFile=/dev/null",
|
|
"-i", privateKeyPath,
|
|
"-R", remotePort+":127.0.0.1:"+localPort,
|
|
fmt.Sprintf("root@%s", remoteHost), "-p"+fmt.Sprintf("%d", remoteSSHPort),
|
|
"sh", "loop.sh",
|
|
)
|
|
}
|
|
|
|
// DynamicForwardLocalRequestToRemote ssh remote port forward
|
|
func DynamicForwardLocalRequestToRemote(remoteHost, privateKeyPath string, remoteSSHPort int, proxyPort int) *exec.Cmd {
|
|
return exec.Command("ssh",
|
|
"-oStrictHostKeyChecking=no",
|
|
"-oUserKnownHostsFile=/dev/null",
|
|
"-i", privateKeyPath,
|
|
"-D", fmt.Sprintf("%d", proxyPort),
|
|
fmt.Sprintf("root@%s", remoteHost), "-p"+fmt.Sprintf("%d", remoteSSHPort),
|
|
"sh", "loop.sh",
|
|
)
|
|
}
|