Ssh – Automated ssh-keygen without passphrase, how

scriptingssh

I would like to make an automated script that calls ssh-keygen and creates some pub/private keypairs that I will use later on. In principle everything works fine with….
ssh-keygen -b 2048 -t rsa -f /tmp/sshkey -q
…except that it asks me for the passphrase that would encrypt the keys. This make -at present- the automation difficult.

I could provide a passphrase via the command line argument -N thepassphrase, so to keep the prompt from appearing.
Still I do not even desire to have the keys –additionally secured by encryption– and want the keypairs to be plaintext.

What is a (the best) solution to this problem?

The -q option which supposedly means "quiet/silent" does still not avoid the passphrase interaction. Also I have not found something like this
ssh-keygen ... -q --no-passphrase

Please do not start preaching about or lecture me to the
pro and cons of the "missing passphrase", I am aware of that.
In the interactive form (not as a script) the user can simply hit [ENTER] twice and the key will be saved as plaintext. This is what I want to achieve in a script like this:

#!/bin/bash

command1
command2
var=$(command3)

# this should not stop the script and ask for password
ssh-keygen -b 2048 -t rsa -f /tmp/sshkey -q

Best Answer

This will prevent the passphrase prompt from appearing and set the key-pair to be stored in plaintext (which of course carries all the disadvantages and risks of that):

ssh-keygen -b 2048 -t rsa -f /tmp/sshkey -q -N ""

Using Windows 10 built in SSH

Powershell:

ssh-keygen -b 2048 -t rsa -f C:/temp/sshkey -q -N """"

CMD:

ssh-keygen -b 2048 -t rsa -f C:/temp/sshkey -q -N ""
Related Question