Skip to content

Commit

Permalink
Merge pull request #24 from DBCDK/fix-22
Browse files Browse the repository at this point in the history
Make scp honor SSH_IDENTITY_FILE and SSH_USER
  • Loading branch information
johanot authored Nov 12, 2018
2 parents 9b37448 + 1c5e448 commit 0794c50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions secrets/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type SecretError struct {
func wrap(err error) *SecretError {
return &SecretError{
Err: err,
Fatal: true,
}
}

Expand Down
15 changes: 12 additions & 3 deletions ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,18 @@ func (ctx *SSHContext) MakeTempFile(host Host) (path string, err error) {

func (ctx *SSHContext) UploadFile(host Host, source string, destination string) (err error) {
destinationAndHost := host.GetTargetHost() + ":" + destination
cmd := exec.Command(
"scp", source, destinationAndHost,
)

parts := make([]string, 0)
if ctx.IdentityFile != "" {
parts = append(parts, "-i", ctx.IdentityFile)
}
if ctx.Username != "" {
destinationAndHost = ctx.Username + "@" + destinationAndHost
}

parts = append(parts, source, destinationAndHost)

cmd := exec.Command("scp", parts...)

data, err := cmd.CombinedOutput()
if err != nil {
Expand Down

0 comments on commit 0794c50

Please sign in to comment.