(2014-02-21)
Problem
Brand new switch, can't configure because the CLI console keeps saying:
error: remote side unexpectedly closed connection
...and kicking you out.
Observed with many JunOS OS revs, including 11.4R7.5.
Solution
What is happening is that the initial config is continually trying to rollback to a non-existant config.
Reboot the switch, then from the root OS interface (not the CLI) run
(it will take a while)