@@ -291,7 +291,15 @@ func isValidCert(keyPath string) bool {
291291// Provision a new signed SSH key with the given config
292292func provisionNewKey (config kssh.ConfigFile , keyPath string ) error {
293293 log .Debug ("Generating a new SSH key..." )
294- err := sshutils .GenerateNewSSHKey (keyPath , true , false )
294+
295+ // Make ~/.ssh/ in case it doesn't exist
296+ err := kssh .MakeDotSSH ()
297+ if err != nil {
298+ return err
299+ }
300+
301+ // Generate the key itself and read it
302+ err = sshutils .GenerateNewSSHKey (keyPath , true , false )
295303 if err != nil {
296304 return fmt .Errorf ("Failed to generate a new SSH key: %v" , err )
297305 }
@@ -300,6 +308,7 @@ func provisionNewKey(config kssh.ConfigFile, keyPath string) error {
300308 return fmt .Errorf ("Failed to read the SSH key from the filesystem: %v" , err )
301309 }
302310
311+ // Provision the key
303312 randomUUID , err := uuid .NewRandom ()
304313 if err != nil {
305314 return fmt .Errorf ("Failed to generate a new UUID for the SignatureRequest: %v" , err )
@@ -315,6 +324,7 @@ func provisionNewKey(config kssh.ConfigFile, keyPath string) error {
315324 }
316325 log .Debug ("Received signature from the CA!" )
317326
327+ // Write it to ~/.ssh
318328 err = ioutil .WriteFile (shared .KeyPathToCert (keyPath ), []byte (resp .SignedKey ), 0600 )
319329 if err != nil {
320330 return fmt .Errorf ("Failed to write new SSH key to disk: %v" , err )
0 commit comments