Newly-created SSH keys landed in the home folder rather than `.ssh` folder after creating with `ssh-keygen`

encryptionhigh sierrasshterminal

I used the ssh-keygen utility bundled with High Sierra to create keys, as directed by this page title How to Create SSH Keys with OpenSSH on Linux or macOS at DigitalOcean.com.

Oddly, the prompt to save the new file for keys indicated the .ssh/id_rsa folder. Yet, the new keys were found in my home folder.

Here is my session, replacing a couple things with blah_blah_blah.

I entered a file name of acme. The pair of files named acme & acme.pub were saved to my home folder of /Users/basilbourque, not .ssh.

MacBook-Pro:~ basilbourque$ which ssh-keygen
/usr/bin/ssh-keygen
MacBook-Pro:~ basilbourque$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/basilbourque/.ssh/id_rsa): acme
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in acme.
Your public key has been saved in acme.pub.
The key fingerprint is:
SHA256:blah_blah_blah basilbourque@MacBook-Pro.local
The key's randomart image is:
blah_blah_blah

➥ Any idea why the destination path indicated in the prompt was ignored?

One possible issue: There is no id_rsa folder nested in my .ssh folder, only a known_hosts file is found there.

I ask for two reasons:

  • Mere curiosity.
    • Why would the ssh-keygen utility display a path in the prompt if it is going to ignore that path?
    • Why would the ssh-keygen utility display a path to a non-existent folder?
  • Wondering if this will result in the ssh connection tool failing to find and utilize the keys for logging into a new ssh connection session.

Is there some place I should move these keys so that will be found by the ssh connection tool? (I am new to using ssh.)

Best Answer

You are prompted for a file name, not a folder name (Enter **file** in which to save the key). So if you just reply with a file name the keys will be stored (with that name) in the current directory. You can just move them to .ssh/ manually if necessary. You probably also need to tell ssh to use your keys instead of the default ones (or you rename your keys to the default name).