Fixing deadlock in ssh command