Skip to content

Commit

Permalink
fix: expand home directory references in sshconfig key file
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanholsteijn committed Mar 24, 2022
1 parent 33b6436 commit a4bb8a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"github.com/binxio/gcloudconfig"
sshconfig "github.com/kevinburke/ssh_config"
"github.com/mitchellh/go-homedir"
"golang.org/x/crypto/ssh"
"golang.org/x/oauth2/google"
"gopkg.in/src-d/go-billy.v4/memfs"
Expand Down Expand Up @@ -124,6 +125,9 @@ func getGoogleCredentials(url *neturl.URL) (transport.AuthMethod, error) {
func identityFileAuthentication(user string, host string) (auth transport.AuthMethod, err error) {

var keyFile = sshconfig.Get(host, "IdentityFile")
if keyFile, err = homedir.Expand(keyFile); err != nil {
return nil, err
}

if user == "" {
user = sshconfig.Get(host, "User")
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/google/go-containerregistry v0.1.1
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd
github.com/mitchellh/go-homedir v1.1.0 // indirect
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/tools v0.0.0-20200619210111-0f592d2728bb
Expand Down

0 comments on commit a4bb8a8

Please sign in to comment.