1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-25 14:48:06 +00:00

Merge pull request #83 from galal-hussein/fix_tilde

Fix tilde issue in ssh key path
This commit is contained in:
Alena Prokharchyk
2017-11-30 09:32:21 -08:00
committed by GitHub

View File

@@ -3,6 +3,7 @@ package cluster
import ( import (
"fmt" "fmt"
"os" "os"
"path/filepath"
"strings" "strings"
"syscall" "syscall"
@@ -124,6 +125,8 @@ func checkEncryptedKey(sshKeyPath string) (ssh.Signer, error) {
func privateKeyPath(sshKeyPath string) string { func privateKeyPath(sshKeyPath string) string {
if len(sshKeyPath) == 0 { if len(sshKeyPath) == 0 {
return os.Getenv("HOME") + DefaultSSHKeyPath return os.Getenv("HOME") + DefaultSSHKeyPath
} else if sshKeyPath[:2] == "~/" {
return filepath.Join(os.Getenv("HOME"), sshKeyPath[2:])
} }
return sshKeyPath return sshKeyPath
} }