Technical

SSH doesn’t work as expected in LXC: fix it with a systematic checklist

SSH doesn’t work as expected in LXC: fix it with a systematic checklist

SSH doesn’t work as expected in LXC? It’s usually the container’s network config, sshd not running, or the host firewall blocking port 22. Here’s the checklist I use.

A complex network of cables in a data center with a monitor in the foreground.

Check the container’s network

First, make sure the container has an IP. Run ip a inside the container. If there’s no IP, check the Proxmox config:

pct config 100 | grep net

You should see something like net0: name=eth0,bridge=vmbr0,ip=dhcp. If it’s missing or wrong, fix it in the GUI or with pct set.

Verify sshd is running

Inside the container, check if sshd is installed and running:

systemctl status sshd

If it’s not installed, install it:

apt install openssh-server

Then start it and enable it:

systemctl enable --now sshd
Networking equipment with connected cables, showcasing modern technology infrastructure.

Host firewall

Proxmox’s firewall might be blocking port 22. Check the container’s firewall options in the GUI or with pct firewall. Make sure port 22 is allowed.

Key permissions

If you’re using key auth, the permissions on ~/.ssh and authorized_keys matter. They should be 700 and 600 respectively:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

My take

Most of the time it’s a network config issue. LXC containers don’t get DHCP by default unless you set it. Check that first before messing with sshd. If you’re still stuck, this post on narrowing down VM network issues has some good commands.

Leave a comment

Comments are reviewed before they appear. Your email is never published.