I assumed that I needed to use Linux or install some software to create the private and public keys. However, I was ashamed to know that OpenSSH is installed as standard on Windows 10 the other day (ssh-keygen command can be used), and I was shocked. It is almost the same as the Linux version, but I will introduce it because there are differences specific to the Windows version.
You can embed passphrases and comments when creating private and public keys, but I don't think it's necessary, so specify an empty string in the ssh-keygen parameter.
For linux, it is as follows.
$ cd [where you want to generate private and public keys]
$ ssh-keygen -q -t rsa -b 4096 -C '' -N '' -f id_rsa
If you execute the Linux version of the command at the Windows command prompt as it is, you will get ** error **. .. ..
> cd [where you want to generate private and public keys]
>ssh-keygen -q -t rsa -b 4096 -C '' -N '' -f id_rsa
Saving key "id_rsa" failed: passphrase is too short (minimum five characters)
The error message says that the passphrase is too short, but the cause is that the empty string specification is not recognized correctly. If you want to specify an empty string, you need to type the command as follows.
> cd [where you want to generate private and public keys]
>ssh-keygen.exe -q -t rsa -b 4096 -C "" -N "" -f id_rsa
When using PowerShell, the above command also gives a ** error **.
> cd [where you want to generate private and public keys]
>ssh-keygen.exe -q -t rsa -b 4096 -C "" -N "" -f id_rsa
Enter passphrase (empty for no passphrase): ← Eh ...
The correct answer is as follows.
> cd [where you want to generate private and public keys]
>ssh-keygen.exe -q -t rsa -b 4096 -C '""' -N '""' -f id_rsa
It is welcome that the number of Linux commands that can be used on Windows is increasing, but I think that it may stumble due to a slight difference as in this case. I hope this article helps someone.
Automate ssh-keygen -t rsa so it does not ask for a passphrase Your SSH Keys are made incorrectly
Recommended Posts