File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,11 @@ package mmh
33import (
44 "errors"
55 "io/ioutil"
6+ "strings"
67 "time"
78
9+ "github.com/mitchellh/go-homedir"
10+
811 "github.com/mritd/mmh/utils"
912
1013 "github.com/mritd/sshutils"
@@ -93,6 +96,13 @@ func (s *ServerConfig) authMethod() []ssh.AuthMethod {
9396
9497// privateKeyFile return private key auth method
9598func privateKeyFile (file , password string ) (ssh.AuthMethod , error ) {
99+ if strings .HasPrefix (file , "~" ) {
100+ home , err := homedir .Dir ()
101+ if err != nil {
102+ return nil , err
103+ }
104+ file = strings .Replace (file , "~" , home , 1 )
105+ }
96106 buffer , err := ioutil .ReadFile (file )
97107 if err != nil {
98108 return nil , err
Original file line number Diff line number Diff line change 1- v1.4.0
1+ v1.4.1
You can’t perform that action at this time.
0 commit comments