Search code examples
bashssh-keygen

Automatically no-overwrite in ssh-keygen


If I run

ssh-keygen -t rsa -N "" -f id_rsa

and the file id_rsa already exists, it will prompt me whether I want to overwrite:

id_rsa already exists.
Overwrite (y/n)?

How do I automatically answer no in a bash script? I checked man ssh-keygen but couldn't find any such option.


Solution

  • you could simply do like this: echo "n"|ssh-keygen -t rsa -N "" -f id_rsa