mirror of
https://github.com/rancher/rke.git
synced 2025-09-24 12:58:56 +00:00
Merge pull request #31 from galal-hussein/add_ssh_key_path
Add ssh private key path
This commit is contained in:
@@ -14,8 +14,12 @@ import (
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultSSHKeyPath = "/.ssh/id_rsa"
|
||||
)
|
||||
|
||||
func (c *Cluster) TunnelHosts() error {
|
||||
key, err := checkEncryptedKey()
|
||||
key, err := checkEncryptedKey(c.SSHKeyPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to parse the private key: %v", err)
|
||||
}
|
||||
@@ -85,9 +89,9 @@ func (c *Cluster) SetUpHosts() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkEncryptedKey() (ssh.Signer, error) {
|
||||
func checkEncryptedKey(sshKeyPath string) (ssh.Signer, error) {
|
||||
logrus.Infof("[ssh] Checking private key")
|
||||
key, err := hosts.ParsePrivateKey(privateKeyPath())
|
||||
key, err := hosts.ParsePrivateKey(privateKeyPath(sshKeyPath))
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "decode encrypted private keys") {
|
||||
fmt.Printf("Passphrase for Private SSH Key: ")
|
||||
@@ -96,7 +100,7 @@ func checkEncryptedKey() (ssh.Signer, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
key, err = hosts.ParsePrivateKeyWithPassPhrase(privateKeyPath(), passphrase)
|
||||
key, err = hosts.ParsePrivateKeyWithPassPhrase(privateKeyPath(sshKeyPath), passphrase)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -107,6 +111,9 @@ func checkEncryptedKey() (ssh.Signer, error) {
|
||||
return key, nil
|
||||
}
|
||||
|
||||
func privateKeyPath() string {
|
||||
return os.Getenv("HOME") + "/.ssh/id_rsa"
|
||||
func privateKeyPath(sshKeyPath string) string {
|
||||
if len(sshKeyPath) == 0 {
|
||||
return os.Getenv("HOME") + DefaultSSHKeyPath
|
||||
}
|
||||
return sshKeyPath
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ github.com/docker/distribution 3800056b8832cf6075e78b282ac010131d8687b
|
||||
github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d
|
||||
github.com/docker/go-units 0dadbb0345b35ec7ef35e228dabb8de89a65bf52
|
||||
golang.org/x/net 186fd3fc8194a5e9980a82230d69c1ff7134229f
|
||||
github.com/rancher/types efe8c45673d9e2132cd78cb46e61340b5ffc4421
|
||||
github.com/rancher/types a7111733a50d97a2541c72e794d216105a22b972
|
||||
github.com/opencontainers/go-digest 279bed98673dd5bef374d3b6e4b09e2af76183bf
|
||||
github.com/gogo/protobuf 117892bf1866fbaa2318c03e50e40564c8845457
|
||||
github.com/opencontainers/image-spec 7c889fafd04a893f5c5f50b7ab9963d5d64e5242
|
||||
|
2
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/types.go
generated
vendored
2
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/types.go
generated
vendored
@@ -116,6 +116,8 @@ type RancherKubernetesEngineConfig struct {
|
||||
Authentication AuthConfig `yaml:"auth" json:"auth,omitempty"`
|
||||
// YAML manifest for user provided addons to be deployed on the cluster
|
||||
Addons string `yaml:"addons" json:"addons,omitempty"`
|
||||
// SSH Private Key Path
|
||||
SSHKeyPath string `yaml:"ssh_key_path" json:"sshKeyPath,omitempty"`
|
||||
}
|
||||
|
||||
type RKEConfigHost struct {
|
||||
|
Reference in New Issue
Block a user