How is the seed for ssh-keygen generated? I expect it will take information from /dev/random and request supplementation with system activity if we have insufficient random bits.

An Instructor made these claims which I find suspect. Can you assist in linking documentation to show them either true or false?

"When local keys are built by a user for rsa/dsa/ecdsa encryption types. It builds it using and embedding as a seed some of the key information privately from the system. So in building the private key for rsa it will use ssh_host_rsa_key, username, MAC Address, and /dev/random as a seed for the local private key for the user."


Reading the man page for ssh-keygen does not go into this detail.

Some odd things are used for seeding key-generation. For example, the process ID was shown to be the only somewhat random element in the Debian barely random key gen scandal. I find it odd that the process id was used at all.

LPIC Level 1 Exam2
Lecture: System RSA/DSA Keys


So in building the private key for rsa it will use ssh_host_rsa_key, username, MAC Address, and /dev/random as a seed for my local private key for the user."

No. It is not true. The private key is generated only based some bytes from /dev/random, which are formed into the private key inside OpenSSL.

Host keys are not used, because normal user who generates the keys do not have an access to them. username and hostname are stored only in a comment of the public key (default behavior, but can be changed) and MAC address is not used (at least not in the OpenSSH), as you can find out in the OpenSSH source code.

Not sure how "Debian barely random key gen scandal" is related to this. It was a bug in OpenSSL, which limited the possible keys. It affected OpenSSH, because it is using OpenSSL for crypto operations and random data source.

  • The Debian scandal appears to indicate more inputs are used for seed generation (process ID). This also does not mention the cases when the system reports insufficient random bits and asks for random key presses, mouse movement, and system use unless this only assists /dev/random directly. – StackAbstraction Jun 17 '16 at 17:34
  • Great idea looking at the code, it appears sshkey_generate(type, bits, &private) is the call but I can't find where the function is written. It does not appear to be in ssh-keygen.c – StackAbstraction Jun 17 '16 at 17:40
  • Yes. Process id and other variables that are basically not guessable are somehow internally used as part of the OpenSSL. But nothing so obvious like MAC address. The function sshkey_generate() is defined in sshkey.c – Jakuje Jun 17 '16 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.