Most tutorials for setting up SSH recommend generating the keypair on a client machine. Why exactly is this?

Assuming your communication lines are not compromised, and you delete the private key from the server after acquiring it, is it safe to generate the keys on a remote host?

  • 1
    When you generate an SSH key using the AWS control panel, it does exactly what you say.
    – paj28
    Commented Jul 29, 2016 at 6:53

2 Answers 2


Because most guides are written for people who are not experienced and it is assumed to be safer (by reducing possibilities for mistake) to prevent the private keys from being transmitted/stored outside of the client on which they were generated. ssh-keygen command also automatically sets the limited permissions to the generated private key reducing the number of steps required.

Where you generate the keys and how you distribute them depends solely on the process (in the "management process"-sense). As long as you do not the compromise security by using an insecure generator or an insecure channel, the exact place where you generate the key pair does not matter. It might as well be a third machine.

  • 1
    Thank you for clearing that up. For me it usually is a third machine (maybe virtual), just because it's so easy to generate keys on linux, and my desktops usually are Windows. Commented Jul 29, 2016 at 7:39

Just guessing here, but keys depend on randomness and most servers don't have great sources of entropy. Entropy often comes from mouse movements and typing on the keyboard, things found on clients.

  • 2
    Please don't guess. Entropy also comes from disk and interrupt timings, and servers have plenty of those.
    – Sjoerd
    Commented Jul 29, 2016 at 7:34
  • Plenty of those? Really? You might find this of interest then: blackhat.com/docs/us-15/materials/… "Even without doing 'crypto' there is constant pressure on the entropy pool due to OS activities" What's worse than guessing? Asserting something as true, when it's not. Commented Jul 29, 2016 at 12:53
  • 1
    @Swashbuckler And even worse is relying on self-serving treatises as actual facts.
    – MAP
    Commented Jul 30, 2016 at 2:58
  • @Swashbuckler The authors of the slides you referenced (from 29 onwards) make a mistake of likening entropy_avail counter with an outbound entropy pool, when it's in fact the inbound pool (see this answer). Their conclusions regarding the entropy consumption are thus flawed (they even seem to admit it "[results] not consistent, still doing research" and "entropy use is not well understood").
    – techraf
    Commented Aug 1, 2016 at 6:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .