From 35cc1ef194883e6afa0a4f6fab9b52d7cb0b2685 Mon Sep 17 00:00:00 2001 From: 24sama Date: Mon, 23 May 2022 10:12:43 +0800 Subject: [PATCH] fix: all-in-one mode generate rsa-sha2-512 signature key Signed-off-by: 24sama --- pkg/common/loader.go | 2 +- pkg/common/local_runtime.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/loader.go b/pkg/common/loader.go index 1276f9a7e..4b2e58e8a 100644 --- a/pkg/common/loader.go +++ b/pkg/common/loader.go @@ -77,7 +77,7 @@ func (d *DefaultLoader) Load() (*kubekeyapiv1alpha2.Cluster, error) { } allInOne := kubekeyapiv1alpha2.Cluster{} - if output, err := exec.Command("/bin/sh", "-c", "if [ ! -f \"$HOME/.ssh/id_rsa\" ]; then ssh-keygen -t rsa -P \"\" -f $HOME/.ssh/id_rsa && ls $HOME/.ssh;fi;").CombinedOutput(); err != nil { + if output, err := exec.Command("/bin/sh", "-c", "if [ ! -f \"$HOME/.ssh/id_rsa\" ]; then ssh-keygen -t rsa-sha2-512 -P \"\" -f $HOME/.ssh/id_rsa && ls $HOME/.ssh;fi;").CombinedOutput(); err != nil { return nil, errors.New(fmt.Sprintf("Failed to generate public key: %v\n%s", err, string(output))) } if output, err := exec.Command("/bin/sh", "-c", "echo \"\n$(cat $HOME/.ssh/id_rsa.pub)\" >> $HOME/.ssh/authorized_keys && awk ' !x[$0]++{print > \"'$HOME'/.ssh/authorized_keys\"}' $HOME/.ssh/authorized_keys").CombinedOutput(); err != nil { diff --git a/pkg/common/local_runtime.go b/pkg/common/local_runtime.go index 9f11c99e4..dd7cd6772 100644 --- a/pkg/common/local_runtime.go +++ b/pkg/common/local_runtime.go @@ -41,7 +41,7 @@ func NewLocalRuntime(debug, ingoreErr bool) (LocalRuntime, error) { return localRuntime, fmt.Errorf("current user is %s. Please use root", u.Username) } - if output, err := exec.Command("/bin/sh", "-c", "if [ ! -f \"$HOME/.ssh/id_rsa\" ]; then ssh-keygen -t rsa -P \"\" -f $HOME/.ssh/id_rsa && ls $HOME/.ssh;fi;").CombinedOutput(); err != nil { + if output, err := exec.Command("/bin/sh", "-c", "if [ ! -f \"$HOME/.ssh/id_rsa\" ]; then ssh-keygen -t rsa-sha2-512 -P \"\" -f $HOME/.ssh/id_rsa && ls $HOME/.ssh;fi;").CombinedOutput(); err != nil { return localRuntime, errors.New(fmt.Sprintf("Failed to generate public key: %v\n%s", err, string(output))) } if output, err := exec.Command("/bin/sh", "-c", "echo \"\n$(cat $HOME/.ssh/id_rsa.pub)\" >> $HOME/.ssh/authorized_keys && awk ' !x[$0]++{print > \"'$HOME'/.ssh/authorized_keys\"}' $HOME/.ssh/authorized_keys").CombinedOutput(); err != nil {