# Set Root Password from pve2 Console

**Container**: VMID 5000 (blockscout-1)  
**Password**: L@kers2010  
**Node**: pve2

---

## Method 1: Using `pct enter` (Recommended)

### Step 1: Access pve2 Node

```bash
# SSH to Proxmox host first (if needed)
ssh root@192.168.11.10

# Then SSH to pve2 node
ssh pve2
```

### Step 2: Enter Container Console

```bash
# Enter the container console
pct enter 5000
```

### Step 3: Set Root Password

Once inside the container:

```bash
# Set password interactively
passwd root
```

When prompted:
1. Enter new password: `L@kers2010`
2. Retype new password: `L@kers2010`

**Expected output:**
```
New password: [enter L@kers2010]
Retype new password: [enter L@kers2010]
passwd: password updated successfully
```

### Step 4: Exit Container

```bash
# Exit container console
exit
```

---

## Method 2: Using `pct exec` with `chpasswd` (One-liner)

From pve2 node console:

```bash
# Set password using chpasswd (non-interactive)
pct exec 5000 -- bash -c 'echo "root:L@kers2010" | chpasswd'
```

**Expected output:**
```
# No output means success
```

---

## Method 3: Using `pct exec` with `passwd` (Non-interactive)

From pve2 node console:

```bash
# Set password using passwd with stdin
pct exec 5000 -- bash -c 'echo -e "L@kers2010\nL@kers2010" | passwd root'
```

**Expected output:**
```
New password: Retype new password: passwd: password updated successfully
```

---

## Complete Command Sequence

**From your local machine:**

```bash
# Option A: Two-step SSH (if pve2 is not directly accessible)
ssh root@192.168.11.10 "ssh pve2 'pct exec 5000 -- bash -c \"echo root:L@kers2010 | chpasswd\"'"
```

**From Proxmox host (192.168.11.10):**

```bash
# SSH to pve2
ssh pve2

# Set password
pct exec 5000 -- bash -c 'echo "root:L@kers2010" | chpasswd'

# Verify (optional)
pct exec 5000 -- bash -c 'su - root -c "echo Password set successfully"'
```

**Directly from pve2 console:**

```bash
# Single command
pct exec 5000 -- bash -c 'echo "root:L@kers2010" | chpasswd'
```

---

## Verification

After setting the password, verify it works:

```bash
# Test SSH access (from pve2 or any host)
ssh root@192.168.11.140
# Enter password: L@kers2010

# Or test from within container
pct exec 5000 -- bash -c 'su - root -c "whoami"'
# Should output: root
```

---

## Troubleshooting

### If `pct enter` doesn't work:

```bash
# Check container is running
pct status 5000

# If stopped, start it first
pct start 5000
```

### If `pct exec` fails:

```bash
# Verify container exists and is running
pct list | grep 5000

# Check container permissions
ls -la /etc/pve/nodes/pve2/lxc/5000.conf
```

### If password contains special characters:

The password `L@kers2010` contains `@` which may need escaping in some shells. The `chpasswd` method handles this correctly, but if issues occur:

```bash
# Use single quotes to prevent shell interpretation
pct exec 5000 -- bash -c 'echo "root:L@kers2010" | chpasswd'

# Or escape the @ symbol
pct exec 5000 -- bash -c "echo 'root:L@kers2010' | chpasswd"
```

---

## Quick Reference

**Easiest method (one command from pve2):**
```bash
pct exec 5000 -- bash -c 'echo "root:L@kers2010" | chpasswd'
```

**Interactive method (if you prefer confirmation):**
```bash
pct enter 5000
passwd root
# Enter password twice when prompted
exit
```

---

**Last Updated**: $(date)

