diff --git a/endpoint_test.go b/endpoint_test.go index e1ed416..3176c86 100644 --- a/endpoint_test.go +++ b/endpoint_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/elliotchance/sshtunnel" + "github.com/jamesgdiaz/sshtunnel" ) func TestCreateEndpoint(t *testing.T) { diff --git a/go.mod b/go.mod index b2bcd84..144bb9a 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ -module github.com/elliotchance/sshtunnel +module github.com/jamesgdiaz/sshtunnel go 1.13 require golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c + +replace github.com/jamesgdiaz/sshtunnel => github.com/elliotchance/sshtunnel v1.6.1 diff --git a/private_key_file.go b/private_key_file.go index ac07ec8..9720d7e 100644 --- a/private_key_file.go +++ b/private_key_file.go @@ -19,3 +19,18 @@ func PrivateKeyFile(file string) ssh.AuthMethod { return ssh.PublicKeys(key) } + +// All credits go to the author fagnercarvalho +func PrivateKeyFileWithPassphrase(file string, passphrase string) ssh.AuthMethod { + buffer, err := os.ReadFile(file) + if err != nil { + return nil + } + + key, err := ssh.ParsePrivateKeyWithPassphrase(buffer, []byte(passphrase)) + if err != nil { + return nil + } + + return ssh.PublicKeys(key) +}