I want to automate user creation along with the rsa key generation in a shell script. But while generating the rsa key we need to give inputs for these three things.

  • Enter file in which to save the key (/root/.ssh/id_rsa):
  • Enter passphrase (empty for no passphrase):
  • Enter same passphrase again:

I want to a custom path for the id_rsa file(the first one) and blank for the passphrase.

I tried to achieve this via send command, but it didn't work. Can anyone help me on this?

1 Answer 1


From man ssh-keygen:

     ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa | rsa1]
                [-N new_passphrase] [-C comment] [-f output_keyfile]

You'll want to do something like this:

ssh-keygen -t rsa -N "" -f /wherever/you/want/id_rsa

If you want to silence ssh-keygen's messages, add the -q option to the command line.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .