ssh_util: Turn open() into a context manager.

The previous approach closed the SFTPClient too early. And before
creating hacky solutions for that, let's use a context manager here.

This should finally fix key uploading.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
ssh_util: Rewrite event loop in invoke_shell().

We're now setting non-blocking mode for sys.stdin, and resetting it on
cleanup/exit. This especially makes input escape sequences much more
responsive. Also, we're now reading on a per-char basis from the
channel, which works around buffering issues and needs to be properly
fixed later. But for now it does what we want.

Also removing the comment referencing Paramiko's demo code, because
we're already differing from the code and the difference will increase
during the work on the Paramiko integration.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
ssh_util: Handle term resizes in invoke_shell().

This ends up being more code that we wish it to be, because we not only
have to install (and clean up) a handler for SIGWINCH, but also properly
detect interruption of the select system call (thus checking
select.error for errno 4, aka EINTR).

Signed-off-by: aszlig <aszlig@redmoonstudios.org>