Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to generate a new SSH key:

$ ssh-keygen -t rsa -C "newkey"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/z/.ssh/id_rsa): newkey
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in newkey.
Your public key has been saved in newkey.pub.

but .ssh/ is still the same:

ls ~/.ssh/*.pub

What am I doing wrong?

share|improve this question
up vote 16 down vote accepted

The key is generated in your current working directory i.e. the directory you were in while running the command.

The prompt

Enter file in which to save the key (/home/z/.ssh/id_rsa):

will default to the file ~/.ssh/id_rsa if you don't provide anything.

If you give an input, that will be treated as:

  • Full (absolute) path to the end filename if starts with /

  • Relative to the $PWD if the path is relative (does not start with /)

So check your current working directory, not ~/.ssh/.

share|improve this answer

You entered a relative path, not an absolute path, so the key will be saved in your present working directory. Try instead entering /home/z/.ssh/newkey, or just look for the public and private keys in your current directory and move them to ~/.ssh.

share|improve this answer

Take a look at the line with:Enter file in which save the key, where you answered newkey. As you can see in the example (/home/z/.ssh/id_rsa), you need to enter the path too! As you entered newkey, it means ./newkey and ./newkey.pub. So use ls in the current directory and you will see those files!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.