Make SSH key saving more robust