From 9f6e1c774b08c33ef1c55cf48fa49ffffa0113ad Mon Sep 17 00:00:00 2001 From: Caleb Brose <5447118+cmbrose@users.noreply.github.com> Date: Mon, 13 Jun 2022 19:31:44 +0000 Subject: [PATCH] Check for key already exists --- pkg/cmd/codespace/ssh.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/codespace/ssh.go b/pkg/cmd/codespace/ssh.go index becafafdf..e8b5d039c 100644 --- a/pkg/cmd/codespace/ssh.go +++ b/pkg/cmd/codespace/ssh.go @@ -127,7 +127,9 @@ func (a *App) SSH(ctx context.Context, sshArgs []string, opts sshOptions) (err e if shouldGenerateSSHKeys(args, opts) && sshContext.HasKeygen() { keyPair, err := sshContext.GenerateSSHKey("codespaces", "") if err != nil { - return fmt.Errorf("failed to generate ssh keys: %s", err) + if _, ok := err.(*ssh.KeyAlreadyExistsError); !ok { + return fmt.Errorf("failed to generate ssh keys: %s", err) + } } startSSHOptions.UserPublicKeyFile = keyPair.PublicKeyPath