Alex's solution does suppress errors, and he almost got the cause right, but it does not allow you to answer any questions (which is fine when you have preseeded the answers and are running from a script, but real annoying when you are trying new packages). The core issue is an interaction between the assumptions made by ssh and debconf's various frontends.
Let's start with ssh. ssh assumes that when you do not specify a remote command you want a pty on the remote end and that you specify a remote you don't (which works remarkably well 90% of the time, just not this one). This can be overridden by the
-t option which forces a pty or the
-T option which forces no pty (or the corresponding config file options). Further when using a pty the
TERM environment variable is copied (exceptions may apply check documentation for completed details and official sweepstakes entry form). Also of note the
-x option disables X11 forwarding and
-X enables it.
Debconf itself has no interactivity requirements (by design), but the various frontends do, and each one has different requirements.
I believe the best looking frontend is gnome (there is also a ked front end that I did not get working). The gnome frontend (and the kde one as well) requires some non-default libraries and a X11 server, therefore the command line to force the gnome frontend (once the appropriate libraries are installed) would be
ssh -X <remote_srv> "DEBIAN_FRONTEND=gnome apt-get autoremove"
or if you prefer kde
ssh -X <remote_srv> "DEBIAN_FRONTEND=kde apt-get autoremove"
The dialog frontend (the default) requires a pty and a terminal with a minimum level of functionality specified in the TERM variable (in practice this is anything with a complete terminfo description except dumb).
ssh -t <remote_srv> "TERM=$TERM DEBIAN_FRONTEND=dialog apt-get autoremove"
ssh -t <remote_srv> "apt-get autoremove"
the readline frontend has less stringent requirements and will work with dumb terminals, but will need a pty.
ssh -t <remote_srv> "DEBIAN_FRONTEND=readline apt-get autoremove"
The editor frontend depends on an editor which would have specific requirements depending on the editor.
ssh -t <remote_srv> "DEBIAN_FRONTEND=editor EDITOR=vi apt-get autoremove"
ssh -X <remote_srv> "DEBIAN_FRONTEND=editor EDITOR=gvim\ -f apt-get autoremove"
The noninteractive frontend has no requirements but it does not ask any questions (which may or may not be what you want).
ssh <remote_srv> "DEBIAN_FRONTEND=noninteractive apt-get autoremove"