Centos 7 vs ubuntu 18 missing /etc/ssh/sshd_config?

LXD noob who is trying to setup allowing SSH connections directly into my LXD guest containers for Ubuntu 18.04 and CentOS 7.5 but seems CentOS version has a missing /etc/ssh/sshd_config ? I am following info at https://stackoverflow.com/a/21874613/272648

on Ubuntu container

lxc exec ubuntu18 -- ls -alh /etc/ssh/        
total 596K
drwxr-xr-x  2 root root 4.0K Jun  4 20:16 .
drwxr-xr-x 87 root root 4.0K Jun  4 20:16 ..
-rw-r--r--  1 root root 541K Feb 10 02:31 moduli
-rw-r--r--  1 root root 1.6K Feb 10 02:31 ssh_config
-rw-------  1 root root  668 Jun  4 17:46 ssh_host_dsa_key
-rw-r--r--  1 root root  603 Jun  4 17:46 ssh_host_dsa_key.pub
-rw-------  1 root root  227 Jun  4 17:46 ssh_host_ecdsa_key
-rw-r--r--  1 root root  175 Jun  4 17:46 ssh_host_ecdsa_key.pub
-rw-------  1 root root  399 Jun  4 17:46 ssh_host_ed25519_key
-rw-r--r--  1 root root   95 Jun  4 17:46 ssh_host_ed25519_key.pub
-rw-------  1 root root 1.7K Jun  4 17:46 ssh_host_rsa_key
-rw-r--r--  1 root root  395 Jun  4 17:46 ssh_host_rsa_key.pub
-rw-r--r--  1 root root  338 Jun  4 20:16 ssh_import_id
-rw-r--r--  1 root root 3.2K May 22 10:54 sshd_config

on CentOS 7.5 container

lxc exec centos75 -- ls -alh /etc/ssh/
total 584K
drwxr-xr-x  2 root root 4.0K Jun  4 02:22 .
drwxr-xr-x 59 root root 4.0K Jun  4 17:55 ..
-rw-r--r--  1 root root 569K Apr 11 04:21 moduli
-rw-r--r--  1 root root 2.3K Apr 11 04:21 ssh_config
lxc list
+----------+---------+----------------------+-----------------------------------------------+------------+-----------+
|   NAME   |  STATE  |         IPV4         |                     IPV6                      |    TYPE    | SNAPSHOTS |
+----------+---------+----------------------+-----------------------------------------------+------------+-----------+
| centos75 | RUNNING | 10.71.164.168 (eth0) | fd42:769c:ebd9:a0f7:216:3eff:fefd:23a2 (eth0) | PERSISTENT | 1         |
+----------+---------+----------------------+-----------------------------------------------+------------+-----------+
| ubuntu18 | RUNNING | 10.71.164.145 (eth0) | fd42:769c:ebd9:a0f7:216:3eff:fe42:4ca8 (eth0) | PERSISTENT | 2         |
+----------+---------+----------------------+-----------------------------------------------+------------+-----------+

Am I missing a step ?

The Ubuntu cloud images include sshd by default, the CentOS images do not. yum install openssh or something along those lines should get CentOS into the same state as Ubuntu.

1 Like

Also, that post on stackoverflow is about LXC, not LXD. See Comparing LXD vs. LXC for the differences.
An easy way to figure out whether a tutorial is about LXC or LXD, is when they use commands like lxc-start (with dash) (these are old LXC), or whether they use commands like lxc launch ubuntu: (with space) (these are the new LXD).

There are two main repositories with containers images, ubuntu: and images:. To see what’s in them, run lxc image list ubuntu: and lxc image list images:.

As you are learning, go through the posts at LXD 2.0: Blog post series [0/12] | Stéphane Graber's website to get a thorough idea on what you can do with LXD.

Also, see at The LXD tutorials of Simos for my entry-level tutorials.

1 Like

@stgraber thanks openssh-server yum package is what i needed :slight_smile:

lxc exec centos75 -- yum -y install openssh openssh-server
lxc exec centos75 -- systemctl enable sshd
lxc exec centos75 -- systemctl restart sshd
lxc exec centos75 -- systemctl status sshd
lxc exec centos75 -- sed -i 's|#Port 22|Port 522|' /etc/ssh/sshd_config
lxc exec centos75 -- grep Port /etc/ssh/sshd_config
lxc exec centos75 -- systemctl restart sshd
lxc exec centos75 -- systemctl status sshd
lxc exec centos75 -- grep Port /etc/ssh/sshd_config
Port 522
#GatewayPorts no

Thanks @simos yes it’s confusing for a noob so thanks for the pointing me in right direction :slight_smile:

Similar problems here but I’m running on Debian (snap running lxd all on debian stretch running a debian stretch container).

root@debian-research1:~# ls -alh /etc/ssh/
total 576K
drwxr-xr-x 1 root root 294 Jun 2 23:09 .
drwxr-xr-x 1 root root 2.6K Jun 4 13:06 …
-rw-r–r-- 1 root root 541K Nov 18 2017 moduli
-rw-r–r-- 1 root root 1.7K Nov 18 2017 ssh_config
-rw------- 1 root root 227 Jun 2 23:09 ssh_host_ecdsa_key
-rw-r–r-- 1 root root 183 Jun 2 23:09 ssh_host_ecdsa_key.pub
-rw------- 1 root root 411 Jun 2 23:09 ssh_host_ed25519_key
-rw-r–r-- 1 root root 103 Jun 2 23:09 ssh_host_ed25519_key.pub
-rw------- 1 root root 1.7K Jun 2 23:09 ssh_host_rsa_key
-rw-r–r-- 1 root root 403 Jun 2 23:09 ssh_host_rsa_key.pub
-rw-r–r-- 1 root root 3.3K Mar 1 15:17 sshd_config

Not sure what’s causing the issues but on containers setup and started using lxd 2.xx I can used x2go to connect. Containers set up using lxd3.0 no dice - – absolutely can’t connect using x2go although I can connect using just ssh.