mirror of
https://github.com/rancher/rke.git
synced 2025-06-27 07:50:30 +00:00
This addresses users issues in being unable to use RKE command line using SSH_AUTH_SOCK. On OSX the socket env var is set, but nothing is listening. Also, Linux users have reported issues. To address this the default mode is to not use SSH Agent Auth. A user must set it explicitly in either the config file or on the CLI. The only way to use a passphrase protected key file is with a properly configured SSH Agent and using SSH Agent Auth.
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/rancher/types/apis/management.cattle.io/v3"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var sshCliOptions = []cli.Flag{
|
|
cli.BoolFlag{
|
|
Name: "ssh-agent-auth",
|
|
Usage: "Use SSH Agent Auth defined by SSH_AUTH_SOCK",
|
|
},
|
|
}
|
|
|
|
func resolveClusterFile(ctx *cli.Context) (string, string, error) {
|
|
clusterFile := ctx.String("config")
|
|
fp, err := filepath.Abs(clusterFile)
|
|
if err != nil {
|
|
return "", "", fmt.Errorf("failed to lookup current directory name: %v", err)
|
|
}
|
|
file, err := os.Open(fp)
|
|
if err != nil {
|
|
return "", "", fmt.Errorf("Can not find cluster configuration file: %v", err)
|
|
}
|
|
defer file.Close()
|
|
buf, err := ioutil.ReadAll(file)
|
|
if err != nil {
|
|
return "", "", fmt.Errorf("failed to read file: %v", err)
|
|
}
|
|
clusterFileBuff := string(buf)
|
|
return clusterFileBuff, clusterFile, nil
|
|
}
|
|
|
|
func setOptionsFromCLI(c *cli.Context, rkeConfig *v3.RancherKubernetesEngineConfig) (*v3.RancherKubernetesEngineConfig, error) {
|
|
// If true... override the file.. else let file value go through
|
|
if c.Bool("ssh-agent-auth") {
|
|
rkeConfig.SSHAgentAuth = c.Bool("ssh-agent-auth")
|
|
}
|
|
return rkeConfig, nil
|
|
}
|