feat(scan): add -ssh-config option #417 (#660)

This commit is contained in:
Kota Kanbe
2018-05-31 12:39:46 +09:00
committed by GitHub
parent 92f36ca558
commit 399a08775e
4 changed files with 42 additions and 18 deletions

View File

@@ -271,25 +271,29 @@ func sshExecExternal(c conf.ServerInfo, cmd string, sudo bool) (result execResul
return sshExecNative(c, cmd, sudo)
}
home, err := homedir.Dir()
if err != nil {
msg := fmt.Sprintf("Failed to get HOME directory: %s", err)
result.Stderr = msg
result.ExitStatus = 997
return
}
controlPath := filepath.Join(home, ".vuls", `controlmaster-%r-`+c.ServerName+`.%p`)
defaultSSHArgs := []string{"-tt"}
defaultSSHArgs := []string{
"-tt",
"-o", "StrictHostKeyChecking=yes",
"-o", "LogLevel=quiet",
"-o", "ConnectionAttempts=3",
"-o", "ConnectTimeout=10",
"-o", "ControlMaster=auto",
"-o", fmt.Sprintf("ControlPath=%s", controlPath),
"-o", "Controlpersist=10m",
if !conf.Conf.SSHConfig {
home, err := homedir.Dir()
if err != nil {
msg := fmt.Sprintf("Failed to get HOME directory: %s", err)
result.Stderr = msg
result.ExitStatus = 997
return
}
controlPath := filepath.Join(home, ".vuls", `controlmaster-%r-`+c.ServerName+`.%p`)
defaultSSHArgs = append(defaultSSHArgs,
"-o", "StrictHostKeyChecking=yes",
"-o", "LogLevel=quiet",
"-o", "ConnectionAttempts=3",
"-o", "ConnectTimeout=10",
"-o", "ControlMaster=auto",
"-o", fmt.Sprintf("ControlPath=%s", controlPath),
"-o", "Controlpersist=10m",
)
}
if conf.Conf.Vvv {
defaultSSHArgs = append(defaultSSHArgs, "-vvv")
}