From 3ef77ac92dd733d3acd9403d8df07b71866ecf25 Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Thu, 4 Feb 2021 10:22:06 -0600 Subject: [PATCH] fix: use 0600 for private key in config-ssh --- internal/cmd/configssh.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/cmd/configssh.go b/internal/cmd/configssh.go index 3077ae7a..57b88651 100644 --- a/internal/cmd/configssh.go +++ b/internal/cmd/configssh.go @@ -81,6 +81,7 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st if err != nil { return xerrors.Errorf("write to ssh config file %q: %s", *configpath, err) } + _ = os.Remove(privateKeyFilepath) return nil } @@ -170,7 +171,7 @@ func writeSSHKey(ctx context.Context, client *coder.Client, privateKeyPath strin if err != nil { return err } - return ioutil.WriteFile(privateKeyPath, []byte(key.PrivateKey), 0400) + return ioutil.WriteFile(privateKeyPath, []byte(key.PrivateKey), 0600) } func makeNewConfigs(userName string, envs []coderutil.EnvWithPool, privateKeyFilepath string) string {