[JENKINS-18214] fail to migrate legacy ssh-slaves private key

split upgrade into smaller methods for readability
don't override privatekey variable with private key content then use it as path