SSH connection: move the su/sudo prompt handling code to a method