diff --git a/cli/internal/cmd/ssh.go b/cli/internal/cmd/ssh.go index c5085047e..d0e35818e 100644 --- a/cli/internal/cmd/ssh.go +++ b/cli/internal/cmd/ssh.go @@ -11,6 +11,7 @@ import ( "crypto/ed25519" "crypto/rand" "fmt" + "os" "time" "github.com/edgelesssys/constellation/v2/internal/constants" @@ -52,6 +53,14 @@ func runSSH(cmd *cobra.Command, _ []string) error { return err } + _, err = fh.Stat(constants.TerraformWorkingDir) + if os.IsNotExist(err) { + return fmt.Errorf("Directory %q does not exist. Please make sure that you are in your constellation workspace.", constants.TerraformWorkingDir) + } + if err != nil { + return err + } + // NOTE(miampf): Since other KMS aren't fully implemented yet, this commands assumes that the cKMS is used and derives the key accordingly. var mastersecret uri.MasterSecret if err = fh.ReadJSON(fmt.Sprintf("%s.json", constants.ConstellationMasterSecretStoreName), &mastersecret); err != nil { @@ -108,7 +117,7 @@ func runSSH(cmd *cobra.Command, _ []string) error { } debugLogger.Debug("Signed certificate", "certificate", string(ssh.MarshalAuthorizedKey(&certificate))) - fh.Write(fmt.Sprintf("%s/ca_cert.pub", constants.TerraformWorkingDir), ssh.MarshalAuthorizedKey(&certificate), file.OptOverwrite, file.OptMkdirAll) + fh.Write(fmt.Sprintf("%s/ca_cert.pub", constants.TerraformWorkingDir), ssh.MarshalAuthorizedKey(&certificate), file.OptOverwrite) fmt.Printf("You can now connect to a node using 'ssh -F %s/ssh_config -i '.\nYou can obtain the private node IP via the web UI of your CSP.\n", constants.TerraformWorkingDir) return nil