Ubuntu – Unable to initialize frontend: dialog when using ssh


I am executing the following command over ssh in a testing environment, as root:

ssh <remote_srv> "apt-get autoremove"

In my sshd_config I have "PermitRootLogin without-password" and I have added the id_rsa.pub of root to the authorized_keys file on the remote server.

Nevertheless I get following errors:

debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype

I have looked this up in de man pages of ssh, but couldn't wrap my mind around the explanation on pseudo-terms and ttys.

Is there anybody who can explain above errors? I guess it's a missing option, but which?

Both platforms are Ubuntu 14.04 LTS.

Best Answer

I believe it has something to do with the fact that apt-get autoremove is being run in a non-interactive shell. See Is it possibe to answer dialog questions when installing under docker?

The solution appears to be to prefix the command with DEBIAN_FRONTEND=noninteractive:

ssh <remote_srv> "DEBIAN_FRONTEND=noninteractive apt-get autoremove"