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
Besides resources like CPU the command needs available entropy. I could not get a reliable information if
ssh-keygenwould use/dev/randomor/dev/urandomfor your case. The usage of/dev/randomwould explain differences of execution time./dev/randomblocks 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.