diff --git a/zfs_replication_exporter.go b/zfs_replication_exporter.go index 67aec4c..2763f43 100644 --- a/zfs_replication_exporter.go +++ b/zfs_replication_exporter.go @@ -78,11 +78,15 @@ func init() { func newPublicKey() ([]ssh.AuthMethod, error) { var signers []ssh.AuthMethod - - for _, path := range []string{ + possiblePaths := []string{ filepath.Join(os.Getenv("HOME"), ".ssh", "id_dsa"), filepath.Join(os.Getenv("HOME"), ".ssh", "id_rsa"), - } { + } + if p := os.Getenv("SSH_PRIVATE_KEY"); p != "" { + possiblePaths = append([]string{p}, possiblePaths...) + } + + for _, path := range possiblePaths { // A public key may be used to authenticate against the remote // server by using an unencrypted PEM-encoded private key file. @@ -97,6 +101,7 @@ func newPublicKey() ([]ssh.AuthMethod, error) { return nil, fmt.Errorf("unable to read private key %q: %v", path, err) } + glog.Infof("Using private key %q", path) // Create the Signer for this private key. signer, err := ssh.ParsePrivateKey(key) if err != nil {