Automate ssh-keygen -t rsa so it does not ask for a passphrase

I need to automate ssh-keygen -t rsa with out a password i.e. enter at the prompt.
How can I do that from a shell script?


Solution 1:

To generate a SSH keypair without being prompted for a passphrase you can do the following:

$ ssh-keygen -f id_rsa -t rsa -N ''

Solution 2:

If you need to do this from PowerShell in windows use:

ssh-keygen -f $Name -t rsa -N '""'

note you also have to ensure the git bin directory is in your path:

$sshPath = "<path>\git\bin\"

$env:path += ";$sshPath"

Then to use it in PoshGit it's just:

Add-SshKey "<path>\.shh\KeyFilename"