Skip to content

Commit

Permalink
stop warning msg of scp because of conflicting known_hosts file by us…
Browse files Browse the repository at this point in the history
…ing /dev/null
  • Loading branch information
mhewedy committed May 10, 2020
1 parent 935370d commit 3983e9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ func VBoxManage(args ...string) *cmd {
}
}

func Scp(args ...string) *cmd {
func Scp(extraArgs ...string) *cmd {
args := []string{"-q",
"-i", db.PrivateKeyPath,
"-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
}

return &cmd{
command: "scp",
args: args,
args: append(args, extraArgs...),
}
}

Expand All @@ -27,18 +33,16 @@ func Arp(args ...string) *cmd {
}

func Ssh(ipAddr string, extraArgs ...string) *cmd {

args := []string{"-i", db.PrivateKeyPath,
"-o", "StrictHostKeyChecking=no",
"-o", "GlobalKnownHostsFile=/dev/null",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "LogLevel=error",
db.Username + "@" + ipAddr}
args = append(args, extraArgs...)

return &cmd{
command: "ssh",
args: args,
args: append(args, extraArgs...),
}
}

Expand Down
4 changes: 2 additions & 2 deletions command/scp/scp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func CopyToVM(vmName string, localFile string, vmFile string) error {
return err
}

_, err = command.Scp("-i", db.PrivateKeyPath, localFile, db.Username+"@"+ipAddr+":"+vmFile).Call()
_, err = command.Scp(localFile, db.Username+"@"+ipAddr+":"+vmFile).Call()

return err
}
Expand All @@ -28,7 +28,7 @@ func CopyToLocalCWD(vmName string, vmFile string) error {
return err
}

_, err = command.Scp("-i", db.PrivateKeyPath, db.Username+"@"+ipAddr+":"+vmFile, "./").Call()
_, err = command.Scp(db.Username+"@"+ipAddr+":"+vmFile, "./").Call()

return err
}

0 comments on commit 3983e9d

Please sign in to comment.