From df3f5c72b7b42ba9a48d1ab9c511090688b47c28 Mon Sep 17 00:00:00 2001 From: Raiden Shogun Date: Fri, 11 Aug 2023 00:17:45 +0800 Subject: [PATCH] remove ssh-add and fix calling appendKnownHelper when not needed --- cmd/minikube/cmd/docker-env.go | 12 +++++------- site/content/en/docs/commands/docker-env.md | 1 - translations/pl.json | 1 - translations/ru.json | 1 - translations/strings.txt | 1 - 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/cmd/minikube/cmd/docker-env.go b/cmd/minikube/cmd/docker-env.go index d47d51ae8e2e..4056008726a3 100644 --- a/cmd/minikube/cmd/docker-env.go +++ b/cmd/minikube/cmd/docker-env.go @@ -125,7 +125,6 @@ type DockerShellConfig struct { var ( noProxy bool sshHost bool - sshAdd bool dockerUnset bool defaultNoProxyGetter NoProxyGetter ) @@ -324,9 +323,10 @@ docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/doc // docker-env on containerd depends on nerdctld (https://github.com/afbjorklund/nerdctld) as "docker" daeomn // and nerdctld daemon must be used with ssh connection (it is set in kicbase image's Dockerfile) // so directly set --ssh-host --ssh-add to true, even user didn't specify them - sshAdd = true sshHost = true + } + if sshHost { // start the ssh-agent if err := sshagent.Start(cname); err != nil { exit.Message(reason.SSHAgentStart, err.Error()) @@ -405,7 +405,7 @@ docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/doc exit.Error(reason.InternalDockerScript, "Error generating set output", err) } - if sshAdd { + if sshHost { klog.Infof("Adding %v", d.GetSSHKeyPath()) path, err := exec.LookPath("ssh-add") @@ -420,10 +420,9 @@ docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/doc if err != nil { exit.Error(reason.IfSSHClient, "Error with ssh-add", err) } + // eventually, run something similar to ssh --append-known + appendKnownHelper(nodeName, true) } - - // eventually, run something similar to ssh --append-known - appendKnownHelper(nodeName, true) }, } @@ -685,7 +684,6 @@ func init() { defaultNoProxyGetter = &EnvNoProxyGetter{} dockerEnvCmd.Flags().BoolVar(&noProxy, "no-proxy", false, "Add machine IP to NO_PROXY environment variable") dockerEnvCmd.Flags().BoolVar(&sshHost, "ssh-host", false, "Use SSH connection instead of HTTPS (port 2376)") - dockerEnvCmd.Flags().BoolVar(&sshAdd, "ssh-add", false, "Add SSH identity key to SSH authentication agent") dockerEnvCmd.Flags().StringVar(&shell.ForceShell, "shell", "", "Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh], default is auto-detect") dockerEnvCmd.Flags().StringVarP(&outputFormat, "output", "o", "", "One of 'text', 'yaml' or 'json'.") dockerEnvCmd.Flags().BoolVarP(&dockerUnset, "unset", "u", false, "Unset variables instead of setting them") diff --git a/site/content/en/docs/commands/docker-env.md b/site/content/en/docs/commands/docker-env.md index 2c14f674765b..85eee96df82e 100644 --- a/site/content/en/docs/commands/docker-env.md +++ b/site/content/en/docs/commands/docker-env.md @@ -28,7 +28,6 @@ minikube docker-env [flags] --no-proxy Add machine IP to NO_PROXY environment variable -o, --output string One of 'text', 'yaml' or 'json'. --shell string Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh], default is auto-detect - --ssh-add Add SSH identity key to SSH authentication agent --ssh-host Use SSH connection instead of HTTPS (port 2376) -u, --unset Unset variables instead of setting them ``` diff --git a/translations/pl.json b/translations/pl.json index 2c690f87b22a..5fc5c814b279 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -47,7 +47,6 @@ "A set of key=value pairs that describe feature gates for alpha/experimental features.": "", "Access the Kubernetes dashboard running within the minikube cluster": "Dostęp do dashboardu uruchomionego w klastrze kubernetesa w minikube", "Access to ports below 1024 may fail on Windows with OpenSSH clients older than v8.1. For more information, see: https://minikube.sigs.k8s.io/docs/handbook/accessing/#access-to-ports-1024-on-windows-requires-root-permission": "", - "Add SSH identity key to SSH authentication agent": "", "Add an image into minikube as a local cache, or delete, reload the cached images": "", "Add an image to local cache.": "Dodaj obraz do lokalnego cache", "Add host key to SSH known_hosts file": "Dodaj klucz hosta do pliku known_hosts", diff --git a/translations/ru.json b/translations/ru.json index 48665e6ea3e0..2056e187a607 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -42,7 +42,6 @@ "A set of key=value pairs that describe feature gates for alpha/experimental features.": "", "Access the Kubernetes dashboard running within the minikube cluster": "", "Access to ports below 1024 may fail on Windows with OpenSSH clients older than v8.1. For more information, see: https://minikube.sigs.k8s.io/docs/handbook/accessing/#access-to-ports-1024-on-windows-requires-root-permission": "", - "Add SSH identity key to SSH authentication agent": "", "Add an image into minikube as a local cache, or delete, reload the cached images": "", "Add an image to local cache.": "", "Add host key to SSH known_hosts file": "", diff --git a/translations/strings.txt b/translations/strings.txt index 530e831570ce..10b33109c2ab 100644 --- a/translations/strings.txt +++ b/translations/strings.txt @@ -42,7 +42,6 @@ "A set of key=value pairs that describe feature gates for alpha/experimental features.": "", "Access the Kubernetes dashboard running within the minikube cluster": "", "Access to ports below 1024 may fail on Windows with OpenSSH clients older than v8.1. For more information, see: https://minikube.sigs.k8s.io/docs/handbook/accessing/#access-to-ports-1024-on-windows-requires-root-permission": "", - "Add SSH identity key to SSH authentication agent": "", "Add an image into minikube as a local cache, or delete, reload the cached images": "", "Add an image to local cache.": "", "Add host key to SSH known_hosts file": "",