Skip to content

Commit

Permalink
feat: Add SSH options (-o param) support
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Jun 25, 2023
1 parent a155d44 commit 801fd19
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type ConfigMeta struct {
type ConfigHost struct {
SSHTarget string `yaml:"ssh_target"`
SSHPassword string `yaml:"ssh_password"`
SSHOptions []string `yaml:"ssh_options"`
SudoPassword string `yaml:"sudo_password"`
Vars map[string]interface{} `yaml:"vars"`
}
Expand Down
1 change: 1 addition & 0 deletions pkg/libtask/libtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package libtask
type TaskInput struct {
SSHTarget string
SSHPassword string
SSHOptions []string
NoStrictHostKeyChecking bool
Sudo bool
SudoPassword string
Expand Down
1 change: 1 addition & 0 deletions pkg/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func Run(
taskInput := libtask.TaskInput{
SSHTarget: host.SSHTarget,
SSHPassword: host.SSHPassword,
SSHOptions: host.SSHOptions,
SudoPassword: host.SudoPassword,
Config: c,
NoStrictHostKeyChecking: c.Global.NoStrictHostKeyChecking,
Expand Down
3 changes: 3 additions & 0 deletions pkg/utils/exec_utils/exec_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func SSH(taskInput libtask.TaskInput, cmdArray ...string) error {
if taskInput.NoStrictHostKeyChecking {
args = append([]string{"-o", "StrictHostKeyChecking=no"}, args...)
}
for _, option := range taskInput.SSHOptions {
args = append([]string{"-o", option}, args...)
}
if taskInput.SSHPassword != "" {
return Exec(taskInput, "sshpass", append([]string{"-p", taskInput.SSHPassword, "ssh"}, args...)...)
} else {
Expand Down

0 comments on commit 801fd19

Please # to comment.