Refactored ssh password handling