Support ProxyJump option when using ssh command (#1004)
* Add proxyjump func * Run go mod tidy * Run make fmt
This commit is contained in:
@@ -1035,6 +1035,7 @@ type ServerInfo struct {
|
||||
ServerName string `toml:"-" json:"serverName,omitempty"`
|
||||
User string `toml:"user,omitempty" json:"user,omitempty"`
|
||||
Host string `toml:"host,omitempty" json:"host,omitempty"`
|
||||
JumpServer []string `toml:"jumpServer,omitempty" json:"jumpServer,omitempty"`
|
||||
Port string `toml:"port,omitempty" json:"port,omitempty"`
|
||||
SSHConfigPath string `toml:"sshConfigPath,omitempty" json:"sshConfigPath,omitempty"`
|
||||
KeyPath string `toml:"keyPath,omitempty" json:"keyPath,omitempty"`
|
||||
|
||||
@@ -57,6 +57,11 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error {
|
||||
return xerrors.Errorf("%s is invalid. host is empty", serverName)
|
||||
}
|
||||
|
||||
s.JumpServer = v.JumpServer
|
||||
if len(s.JumpServer) == 0 {
|
||||
s.JumpServer = d.JumpServer
|
||||
}
|
||||
|
||||
switch {
|
||||
case v.Port != "":
|
||||
s.Port = v.Port
|
||||
|
||||
@@ -287,6 +287,10 @@ func sshExecExternal(c conf.ServerInfo, cmd string, sudo bool) (result execResul
|
||||
defaultSSHArgs = append(defaultSSHArgs, "-vvv")
|
||||
}
|
||||
|
||||
if len(c.JumpServer) != 0 {
|
||||
defaultSSHArgs = append(defaultSSHArgs, "-J", strings.Join(c.JumpServer, ","))
|
||||
}
|
||||
|
||||
args := append(defaultSSHArgs, fmt.Sprintf("%s@%s", c.User, c.Host))
|
||||
args = append(args, "-p", c.Port)
|
||||
if 0 < len(c.KeyPath) {
|
||||
|
||||
Reference in New Issue
Block a user