Fixes for SSH key generation.

Closes #514, fixes #512