newspaint

Documenting Problems That Were Difficult To Find The Answer To

LXC Container Reports PTY allocation request failed on channel 0 On SSH Connection

I tried upgrading my LXC from Ubuntu Trusty 14.04 by running sudo apt-get install lxc because, by default, the lxc package was not being upgraded.

But I then had problems getting consoles/terminals with my existing LXC containers.

This problem exhibits itself when attempting to ssh to a LXC container with the following message:

# ssh ubuntu@10.0.3.201
ubuntu@10.0.3.201's password: 
PTY allocation request failed on channel 0

It also exhibits itself when attempting to lxc-console a LXC container:

# sudo lxc-console -n mycontainer
lxc-console: commands.c: lxc_cmd_console: 722 Console -1 invalid, busy or all consoles busy.

(although a workaround is to connect using sudo lxc-console -n mycontainer -t 0).

The issue is that every container config file needs to have some extra lines added:

# required for lxc-console to work
lxc.tty = 4

# requires for interactive SSH to work
lxc.pts = 1024

One other issue I came across was that I would get the following errors when trying to start a container:

# sudo lxc-start -F -n mycontainer
Failed to mount cgroup at /sys/fs/cgroup/systemd: Permission denied
[!!!!!!] Failed to mount API filesystems, freezing.
Freezing execution.

This was bypassed by adding the following to the container’s config file:

# disable apparmour restrictions on container
lxc.aa_profile = unconfined

Leave a comment