I know this is probably google skills deficiency on my behalf but for the love of god I cant shell into a CentOS 7 container on an Ubuntu 17.04 host.

user@ubuntu1704:~$ lxc shell centos7

absolutely nothing happens ... no error and I cant find a way to specify login user and password.

Here is how I launched the container

apt install yum
lxc launch images:centos/7/amd64 centos7

it downloaded the image and launched it. info shows all is fine and has correct ip and everything. By default ssh connections refused (SELinux)

Please help!! very stuck!! Thanks alot !!


SSH is not enabled by default in the centos7 image here is the output of

ssh -vvv root@

OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to [] port 22.
debug1: connect to address port 22: Connection refused
ssh: connect to host port 22: Connection refused
  • There is none ... it completes the cmd and falls back to host shell – a.atlam Oct 5 '17 at 17:55
  • How do you know it is a host shell ? cat /etc/issue or perhaps better rpm --query centos-release – Panther Oct 5 '17 at 17:58
  • From user and ip a – a.atlam Oct 5 '17 at 17:59
  • And hostname ... I mean wouldn't you know your host env from a fresh different distro environment? – a.atlam Oct 5 '17 at 18:02
  • Would you please post more information ? The ssh command and full output as well as the commands I requested. I really can not tell what your problem is with such little information. I can not imagine selinux is running in a LXC container, but perhaps. ssh -vvv user@centos_7_server ? How did you create the centos user or are you using root ? Did you install the ssh server ? Why are you not using lsx-attach to at least obtain a shell and configure centos ? – Panther Oct 5 '17 at 18:04

Found it:

  • For CentOS images: lxc exec my-container -- bash
  • For Ubuntu images: lxc shell my-container, or
  • For Ubuntu images: lxc exec my-container -- sudo --login --user username

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.