Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ssh-keys

People also ask

How do I stop entering passphrase for SSH key?

Use ssh-add to add the keys to the list maintained by ssh-agent. After you add a private key password to ssh-agent, you do not need to enter it each time you connect to a remote host with your public key.

Can I have a SSH key without an passphrase?

A key with no passphrase is reliant upon nobody else being able to get at that key (who wouldn't be able to get at the resources it gives access to anyway). So, if the key grants access to a machine next to it, and both machines have the same level of electronic and physical security, then it's not really any big deal.

Why does SSH keep asking for passphrase?

There may be times in which you don't want the passphrase stored in the keychain, but don't want to have to enter the passphrase over and over again. This will ask you for the passphrase, enter it and it will not ask again until you restart.

Do you have to set a passphrase when creating an SSH Keypair?

SSH keys with passphrase or without it When creating SSH keys, you can create them with or without a passphrase. If you do create a key with passphrase, you will be asked for passphrase every time you try to communicate with your Git repository in Beanstalk.


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

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

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"

$ ssh-keygen -f $HOME/.ssh/id_rsa -t rsa -N ''

Just a correction to answer 2... I found out on my OL and RHEL system the file name should be id_rsa not id.rsa.

So on a OL or RHEL system the command would be:

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

What about :

ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ''

As noted in man ssh-keygen :

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

(that is with openssh-client package in Debian 9.4 stretch : OpenSSH_6.7p1 Debian-5+deb8u4)