create pseudo TTY

As taken from http://serverfault.com/questions/489939/ssh-session-never-closes-when-executing-apt-get-install this
solves problems with apt-get and debconf.
use defer to close the session

Just because its idiomatic.
return error if command failed