All About Enabling SSh In An Lxc Container Vps Through NoVNC Console/ipmi
How to Enable Root SSH Login Inside an LXC Container on a VPS Platform
LXC containers have become a powerful option for VPS hosting, offering fast boot times, low overhead, and excellent performance for cloud environments. But one common challenge administrators face—especially when deploying standard container templates—is that root SSH login is disabled by default.
While this is generally a smart security practice, there are valid situations where enabling root login over SSH inside an LXC container is necessary. For example:
- automated provisioning
- backup or restore scripts
- management agents that authenticate as root
- recovery workflows on private networks
- internal cloud or lab environments
This guide explains exactly how to enable root SSH login inside an LXC container, with clean formatting for Ghost and SEO-focused keywords for LXC, VPS hosting, and Linux virtualization.
Why LXC Containers Disable Root SSH Login
Most LXC templates follow upstream Linux security policies, which usually include:
PermitRootLogin noinsidesshd_config- a locked or passwordless root account
- cloud-init settings preventing SSH login for root
- reliance on a non-root user for administrative access
These settings make sense for public servers—but on a VPS platform or private virtualization stack, there are times when root SSH access is required for automation or advanced administration.
Step 1: Set a Root Password Inside the Container
Root SSH login cannot work until the root account has a valid password.
Start by opening your container’s console (noVNC / serial console / control panel console). Then run:
sudo passwd root
Or, if you’re already logged in as root via the console:
passwd
Choose a strong password.
Once the password is set, the root account becomes active for login.
Step 2: Enable Root SSH Login in sshd_config
Edit the SSH daemon configuration file:
nano /etc/ssh/sshd_config
Find the line:
PermitRootLogin no
Change it to:
PermitRootLogin yes
Also ensure password authentication is allowed:
PasswordAuthentication yes
If these directives don’t exist, add them manually.
Save and exit the editor.
Step 3: Restart SSH to Apply Changes
Apply the updated settings by restarting SSH:
systemctl restart sshd
If your system uses a slightly different service name (like on some older Debian or Alpine LXC templates), you can try:
service ssh restart
SSH is now ready to accept root logins.
Step 4: Test Root SSH Access
From any system with network access to the container, connect using:
ssh root@YOUR_CONTAINER_IP
You should now be able to log in using the password you created.
If the login fails, double-check:
- firewall settings
- container network bridged/NAT configuration
- sshd_config typos
- whether your VPS control panel blocks ports until provisioning completes
Troubleshooting
“Authentication failed” even though the password is correct
Check if PAM is enabled:
grep -i pam /etc/ssh/sshd_config
Ensure the line is uncommented:
UsePAM yes
Then restart SSH again.
Cloud-init keeps disabling root
Edit:
nano /etc/cloud/cloud.cfg
Change:
disable_root: true
to:
disable_root: false
Remove any forced users such as ssh_pwauth: false, then reboot the container.
Unprivileged LXC Containers
If running an unprivileged container, the host configuration may restrict certain operations.
Check the host’s config (if you have access):
lxc.apparmor.profile = unconfinedlxc.cap.drop =
Most VPS hosts already configure this properly for SSH to work.
Is Enabling Root SSH Login Safe?
Root SSH login is safe when used correctly, especially when:
- your VPS is on a trusted network
- SSH rate-limits or firewalls are enabled
- strong passwords or SSH keys are used
- automation tools require direct root access
- container usage is internal or non-public
For public-facing production systems, disabling root SSH login and relying on a non-root user with sudo remains a best practice.
Final Thoughts
Enabling root SSH login inside an LXC container is straightforward once you understand how templates enforce default security. By setting a root password, modifying sshd_config, and restarting the SSH service, you gain full remote access to your container for advanced administration, provisioning, or recovery.
LXC remains a powerful solution for VPS hosting, and having flexible SSH access to the root account can simplify automation, streamline management workflows, and improve your virtualization environment overall.