Files
proxmox/docs/04-configuration/ENABLE_ROOT_SSH_CONTAINER.md
defiQUG cb47cce074 Complete markdown files cleanup and organization
- Organized 252 files across project
- Root directory: 187 → 2 files (98.9% reduction)
- Moved configuration guides to docs/04-configuration/
- Moved troubleshooting guides to docs/09-troubleshooting/
- Moved quick start guides to docs/01-getting-started/
- Moved reports to reports/ directory
- Archived temporary files
- Generated comprehensive reports and documentation
- Created maintenance scripts and guides

All files organized according to established standards.
2026-01-06 01:46:25 -08:00

4.4 KiB

Enable Root SSH Login for Container VMID 5000

Status: Password already set to L@kers2010
Issue: Root SSH login is disabled
Solution: Enable root SSH in container


Quick Commands

Since you can access the LXC container, run these commands inside the container:

Method 1: Via Container Console/Shell

# Access container (you mentioned you can access it now)
pct enter 5000
# Or via console UI

# Inside container, run:
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo sed -i 's/#PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo sed -i 's/PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config

# If PermitRootLogin doesn't exist, add it
if ! grep -q "^PermitRootLogin" /etc/ssh/sshd_config; then
    echo "PermitRootLogin yes" | sudo tee -a /etc/ssh/sshd_config
fi

# Restart SSH service
sudo systemctl restart sshd

# Exit container
exit

Method 2: Via pct exec (One-liner)

From pve2 node or Proxmox host:

# Enable root SSH
pct exec 5000 -- bash -c '
sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config
sudo sed -i "s/PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config
sudo sed -i "s/#PermitRootLogin no/PermitRootLogin yes/" /etc/ssh/sshd_config
sudo sed -i "s/PermitRootLogin no/PermitRootLogin yes/" /etc/ssh/sshd_config
if ! grep -q "^PermitRootLogin" /etc/ssh/sshd_config; then
    echo "PermitRootLogin yes" | sudo tee -a /etc/ssh/sshd_config
fi
sudo systemctl restart sshd
echo "Root SSH enabled"
'

Complete Step-by-Step

Step 1: Access Container

# From pve2 node
pct enter 5000

Step 2: Backup SSH Config

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup

Step 3: Edit SSH Config

# View current config
sudo grep PermitRootLogin /etc/ssh/sshd_config

# Enable root login
sudo sed -i 's/.*PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config

# Or use nano/vi
sudo nano /etc/ssh/sshd_config
# Find PermitRootLogin line and change to:
# PermitRootLogin yes

Step 4: Verify Configuration

# Check the setting
sudo grep PermitRootLogin /etc/ssh/sshd_config

# Should show: PermitRootLogin yes

Step 5: Restart SSH Service

sudo systemctl restart sshd

# Or if systemctl doesn't work:
sudo service ssh restart

Step 6: Exit Container

exit

Step 7: Test SSH Access

# Try SSH to container
ssh root@192.168.11.140
# Password: L@kers2010

Alternative: If Container Uses Different SSH Config Location

Some Ubuntu containers may use different paths:

# Check which SSH config exists
ls -la /etc/ssh/sshd_config
ls -la /etc/ssh/sshd_config.d/

# If using sshd_config.d, create override
echo "PermitRootLogin yes" | sudo tee /etc/ssh/sshd_config.d/99-root-login.conf
sudo systemctl restart sshd

Security Note

⚠️ Security Warning: Enabling root SSH login reduces security. Consider:

  1. Use key-based authentication instead of password
  2. Change default SSH port
  3. Use fail2ban to prevent brute force attacks
  4. Restrict root SSH to specific IPs
# On your local machine, generate key (if you don't have one)
ssh-keygen -t ed25519 -C "your_email@example.com"

# Copy public key to container
ssh-copy-id root@192.168.11.140

# Then disable password authentication
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo systemctl restart sshd

Verification

After enabling root SSH:

# Test SSH access
ssh root@192.168.11.140
# Should prompt for password: L@kers2010

If SSH still doesn't work:

  1. Check SSH service is running: sudo systemctl status sshd
  2. Check firewall: sudo ufw status
  3. Verify IP: ip addr show eth0
  4. Check SSH logs: sudo tail -f /var/log/auth.log

Quick Script

Run this script to enable root SSH:

#!/bin/bash
# Enable root SSH for container VMID 5000

pct exec 5000 -- bash -c '
sudo sed -i "s/.*PermitRootLogin.*/PermitRootLogin yes/" /etc/ssh/sshd_config
if ! grep -q "^PermitRootLogin" /etc/ssh/sshd_config; then
    echo "PermitRootLogin yes" | sudo tee -a /etc/ssh/sshd_config
fi
sudo systemctl restart sshd
echo "✅ Root SSH enabled"
'

Last Updated: $(date)