Create private and public keys using ssh-keygen (difference between Windows 10 and Linux)

1.First of all

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.

2. How to create

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.

2.1. For Linux

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

2.2. For Windows (command prompt)

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

2.3. For Windows (PowerShell)

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

3. Conclusion

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.

reference

Automate ssh-keygen -t rsa so it does not ask for a passphrase Your SSH Keys are made incorrectly

Recommended Posts

Create private and public keys using ssh-keygen (difference between Windows 10 and Linux)
[Samba] File sharing between Linux and Windows machines
Difference between using and import on shield language
What is the difference between Unix and Linux?
Understand cryptocurrency (Bitcoin, Monacoin) protocols: public and private keys
A rough summary of the differences between Windows and Linux
Difference between process and job
Difference between "categorical_crossentropy" and "sparse_categorical_crossentropy"
Difference between regression and classification
Difference between np.array and np.arange
Difference between MicroPython and CPython
Difference between ps a and ps -a
Difference between return and print-Python
Difference between Ruby and Python split
Difference between java and python (memo)
Difference between list () and [] in Python
Difference between SQLAlchemy filter () and filter_by ()
Difference between == and is in python
(Windows10) Install Linux environment and gnuplot.
Memorandum (difference between csv.reader and csv.dictreader)
(Note) Difference between gateway and default gateway
Difference between Numpy randint and Random randint
Create a Linux environment on Windows 10
Difference between sort and sorted (memorial)
Difference between python2 series and python3 series dict.keys ()
[Python] Difference between function and method
Difference between SQLAlchemy flush () and commit ()
Python --Difference between exec and eval
[Python] Difference between randrange () and randint ()
[Python] Difference between sorted and sorted (Colaboratory)