Hi,
It would be hard for me to tell where problem might be, but what you can try to do here is may be to run in debug mode
and when it connects for second time and hangs, I would pause and see where it is right now in the code, somewhere in SSH library or not.
If its waiting for reply then most likely its a server issue.
Hope it helps a little.
Thanks,
Oleg