Why is the duration for ssh-keygen so different?

109 Views Asked by At

When calling ssh-keygen (in my case for a rsa key without passphrase) the time until the call finishes is different. I'm calling it on an embedded linux (4.14) with OpenSSH 8.8. The default keylen is 3072. The duration differs from 30s to 75s and I'm wondering why. The system is quite idle at that time and there is plenty of memory...Any ideas?

/system/bin/ssh-keygen -t rsa -N "" -f /data/ssh/ssh_host_rsa_key

1

There are 1 best solutions below

0
TheFRedFox On

Besides resources like CPU the command needs available entropy. I could not get a reliable information if ssh-keygen would use /dev/random or /dev/urandom for your case. The usage of /dev/random would explain differences of execution time. /dev/random blocks if there is not enough random entropy available to generate a new random value. Entropy can be generated by e.g. moving the mouse, using the keyboard or running other commands generating random data.

In that answer here haveged is being mentioned, which is a daemon generating digital noise and therefore entropy, which could speedup generation of keys in your case.