Merge pull request #182 from alex/expand-user-path
helper/ssh: expand ~'s in the path to a key file
This commit is contained in:
commit
25c560b0f5
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"code.google.com/p/go.crypto/ssh"
|
"code.google.com/p/go.crypto/ssh"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
|
"github.com/mitchellh/go-homedir"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -102,7 +103,11 @@ func PrepareConfig(conf *SSHConfig) (*Config, error) {
|
||||||
User: conf.User,
|
User: conf.User,
|
||||||
}
|
}
|
||||||
if conf.KeyFile != "" {
|
if conf.KeyFile != "" {
|
||||||
key, err := ioutil.ReadFile(conf.KeyFile)
|
fullPath, err := homedir.Expand(conf.KeyFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("Failed to expand home directory: %v", err)
|
||||||
|
}
|
||||||
|
key, err := ioutil.ReadFile(fullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to read key file '%s': %v", conf.KeyFile, err)
|
return nil, fmt.Errorf("Failed to read key file '%s': %v", conf.KeyFile, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue