From 3f08540e4bc63b3020118b8a2df0ce9fce57bf19 Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Sat, 17 Oct 2020 01:44:56 -0500 Subject: [PATCH] Check for perm error in coder config-ssh --- internal/cmd/configssh.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/cmd/configssh.go b/internal/cmd/configssh.go index 3d9afff7..db76b71e 100644 --- a/internal/cmd/configssh.go +++ b/internal/cmd/configssh.go @@ -130,7 +130,10 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st } err = writeSSHKey(ctx, client, privateKeyFilepath) if err != nil { - fmt.Printf("Your private ssh key already exists at \"%s\"\nYou may need to remove the existing file and re-run this command\n", privateKeyFilepath) + if !xerrors.Is(err, os.ErrPermission) { + return xerrors.Errorf("write ssh key: %w", err) + } + fmt.Printf("Your private ssh key already exists at \"%s\"\nYou may need to remove the existing private key file and re-run this command\n\n", privateKeyFilepath) } else { fmt.Printf("Your private ssh key was written to \"%s\"\n", privateKeyFilepath) }