Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/elliotchance/sshtunnel"
"github.com/jamesgdiaz/sshtunnel"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you fork a package you should clone it to the path of the original package so that you don't have to change these.

)

func TestCreateEndpoint(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions private_key_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,18 @@ func PrivateKeyFile(file string) ssh.AuthMethod {

return ssh.PublicKeys(key)
}

// All credits go to the author fagnercarvalho
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on this?

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)
}