From 2f20bfedc4394301af9613e44bfe305b701ee12f Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 2 May 2024 20:20:20 +0200 Subject: sshcmd --- src/c_exec.go | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/c_exec.go') diff --git a/src/c_exec.go b/src/c_exec.go index a1547d4..6829d94 100644 --- a/src/c_exec.go +++ b/src/c_exec.go @@ -82,20 +82,20 @@ func c_exec_cmd(cmd_fmt, cmd_env []string, silent bool) (error, string) { } func c_format_ssh_jump(host *HostNode) string { - jump_fmt := "-oProxyCommand=ssh" - if len(host.Jump.Priv) > 0 { - jump_fmt += " -i " + host.Jump.Priv - } - if host.Jump.Port != 0 { - jump_fmt += " -p " + strconv.Itoa(int(host.Jump.Port)) - } - if len(host.Jump.User) == 0 { - jump_fmt += " root" - } else { - jump_fmt += " " + host.Jump.User - } - jump_fmt += "@" + host.Jump.Host + " -W %h:%p" - return jump_fmt + jump_fmt := "-oProxyCommand=ssh" + if len(host.Jump.Priv) > 0 { + jump_fmt += " -i " + host.Jump.Priv + } + if host.Jump.Port != 0 { + jump_fmt += " -p " + strconv.Itoa(int(host.Jump.Port)) + } + if len(host.Jump.User) == 0 { + jump_fmt += " root" + } else { + jump_fmt += " " + host.Jump.User + } + jump_fmt += "@" + host.Jump.Host + " -W %h:%p" + return jump_fmt } func c_format_ssh(host *HostNode, pass string) ([]string, []string) { @@ -114,7 +114,13 @@ func c_format_ssh(host *HostNode, pass string) ([]string, []string) { if host.Port != 0 { cmd_fmt = append(cmd_fmt, "-p", strconv.Itoa(int(host.Port))) } + if len(host.Exec) > 0 { + cmd_fmt = append(cmd_fmt, "-t") + } cmd_fmt = append(cmd_fmt, host.User + "@" + host.Host) + if len(host.Exec) > 0 { + cmd_fmt = append(cmd_fmt, "--", host.Exec) + } return cmd_fmt, nil } -- cgit v1.2.3