Fixed ssh connection handling