Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
99 lines
3.0 KiB
Bash
Executable File
99 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Set root password for a Proxmox LXC container
|
|
# Usage: ./set-container-password.sh <VMID> <PASSWORD>
|
|
|
|
set -euo pipefail
|
|
|
|
# Load IP configuration
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
|
|
|
|
|
|
VMID="${1:-5000}"
|
|
PASSWORD="${2:-L@kers2010}"
|
|
PROXMOX_HOST="${PROXMOX_HOST:-${PROXMOX_HOST_ML110:-192.168.11.10}}"
|
|
|
|
# Node name to IP (for pct exec on correct host)
|
|
get_node_ip() {
|
|
case "$1" in
|
|
ml110) echo "${PROXMOX_HOST_ML110:-192.168.11.10}" ;;
|
|
r630-01) echo "${PROXMOX_HOST_R630_01:-192.168.11.11}" ;;
|
|
r630-02) echo "${PROXMOX_HOST_R630_02:-192.168.11.12}" ;;
|
|
*) echo "$PROXMOX_HOST" ;;
|
|
esac
|
|
}
|
|
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: $0 <VMID> [PASSWORD]"
|
|
echo "Default password: L@kers2010"
|
|
exit 1
|
|
fi
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
|
|
# Find container node
|
|
log_info "Finding container VMID $VMID..."
|
|
# Support sshpass if PROXMOX_PASS or PROXMOX_PASS_ML110 set (for password auth)
|
|
PROXMOX_PASS="${PROXMOX_PASS:-${PROXMOX_PASS_ML110:-}}"
|
|
run_ssh() {
|
|
if [[ -n "$PROXMOX_PASS" ]]; then
|
|
sshpass -p "$PROXMOX_PASS" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 "$@"
|
|
else
|
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 "$@"
|
|
fi
|
|
}
|
|
|
|
CONTAINER_NODE=$(run_ssh root@"$PROXMOX_HOST" \
|
|
"for node in ml110 r630-01 r630-02; do \
|
|
if pvesh get /nodes/\$node/lxc/$VMID/status/current 2>/dev/null | grep -q status; then \
|
|
echo \$node; break; \
|
|
fi; \
|
|
done" 2>/dev/null || echo "")
|
|
|
|
if [ -z "$CONTAINER_NODE" ]; then
|
|
echo "❌ Container VMID $VMID not found on any node"
|
|
exit 1
|
|
fi
|
|
|
|
log_success "Container found on node: $CONTAINER_NODE"
|
|
echo ""
|
|
|
|
# Set password using chpasswd (run pct on node where container lives)
|
|
NODE_IP=$(get_node_ip "$CONTAINER_NODE")
|
|
log_info "Setting root password for container $VMID..."
|
|
if run_ssh root@"$PROXMOX_HOST" \
|
|
"pvesh create /nodes/$CONTAINER_NODE/lxc/$VMID/exec --command 'bash' --arg '-c' --arg \"echo root:$PASSWORD | chpasswd\" 2>/dev/null" 2>&1 | grep -q "UPID\|success"; then
|
|
log_success "Password set successfully via API"
|
|
elif run_ssh root@"$NODE_IP" \
|
|
"pct exec $VMID -- bash -c 'echo \"root:$PASSWORD\" | chpasswd' 2>&1"; then
|
|
log_success "Password set successfully"
|
|
else
|
|
echo "❌ Failed to set password"
|
|
echo ""
|
|
echo "Alternative methods:"
|
|
echo "1. Via Proxmox web UI:"
|
|
echo " - Go to Container $VMID → Options → Password"
|
|
echo " - Set password: $PASSWORD"
|
|
echo ""
|
|
echo "2. Via container console:"
|
|
echo " ssh root@$NODE_IP"
|
|
echo " pct enter $VMID"
|
|
echo " passwd root"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
log_success "Root password for container $VMID set to: $PASSWORD"
|
|
echo ""
|
|
echo "You can now login with:"
|
|
echo " ssh root@<container-ip>"
|
|
echo " Password: $PASSWORD"
|
|
|