Improve error trace debuging in ssh key generation;

* additional check: is dir for key exist?;
* save and show exit code, stdout and stderr info;
* add tests;
* refactoring.

Change-Id: Ic53c561fc72abe1f0292ae200aa1d4ced5954083
Closes-Bug: #1268861