3.6 KiB
3.6 KiB
SSH Access with sshpass
Date: 2025-12-13
Status: ✅ CONFIGURED
Overview
All SSH scripts have been updated to use sshpass with the password from .env file (lines 45-46).
Quick Access Scripts
SSH to ML110-01
./scripts/ssh-ml110-01.sh
SSH to R630-01
./scripts/ssh-r630-01.sh
Execute Commands Remotely
# ML110-01
./scripts/ssh-ml110-01.sh 'pveversion'
./scripts/ssh-ml110-01.sh 'qm list'
./scripts/ssh-ml110-01.sh 'pvesm status'
# R630-01
./scripts/ssh-r630-01.sh 'pveversion'
./scripts/ssh-r630-01.sh 'qm list'
./scripts/ssh-r630-01.sh 'pvesm status'
Manual Commands
Using sshpass Directly
ML110-01:
PROXMOX_PASSWORD=$(sed -n '45,46p' .env | grep PROXMOX_ROOT_PASS | cut -d'=' -f2 | tr -d '"' | tr -d "'")
sshpass -p "$PROXMOX_PASSWORD" ssh root@192.168.11.10
R630-01:
PROXMOX_PASSWORD=$(sed -n '45,46p' .env | grep PROXMOX_ROOT_PASS | cut -d'=' -f2 | tr -d '"' | tr -d "'")
sshpass -p "$PROXMOX_PASSWORD" ssh root@192.168.11.11
Password Source
The password is automatically loaded from .env file:
- Location: Lines 45-46
- Variable:
PROXMOX_ROOT_PASS - Format: Automatically extracted and cleaned
Updated Scripts
1. scripts/ssh-proxmox-nodes.sh
- Displays SSH commands with sshpass
- Shows password status
- Provides verification commands
2. scripts/ssh-ml110-01.sh
- Quick SSH to ML110-01
- Password loaded automatically
- Supports command execution
3. scripts/ssh-r630-01.sh
- Quick SSH to R630-01
- Password loaded automatically
- Supports command execution
4. scripts/test-proxmox-connectivity.sh
- Uses sshpass for SSH tests
- Automatically loads password
- Tests both nodes
Example Usage
Check Proxmox Version
# ML110-01
./scripts/ssh-ml110-01.sh 'pveversion'
# R630-01
./scripts/ssh-r630-01.sh 'pveversion'
List VMs
# ML110-01
./scripts/ssh-ml110-01.sh 'qm list'
# R630-01
./scripts/ssh-r630-01.sh 'qm list'
Check Storage
# ML110-01
./scripts/ssh-ml110-01.sh 'pvesm status'
# R630-01
./scripts/ssh-r630-01.sh 'pvesm status'
Interactive SSH Session
# ML110-01
./scripts/ssh-ml110-01.sh
# R630-01
./scripts/ssh-r630-01.sh
Security Notes
⚠️ Important:
- Password is stored in
.envfile (should be in.gitignore) sshpasspasses password via command line (visible in process list)- For production, consider using SSH keys instead
Recommended: Setup SSH Keys
# Generate key
ssh-keygen -t rsa -b 4096 -f ~/.ssh/proxmox_key
# Copy to both nodes
./scripts/ssh-ml110-01.sh 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys' < ~/.ssh/proxmox_key.pub
./scripts/ssh-r630-01.sh 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys' < ~/.ssh/proxmox_key.pub
# Then use key-based auth
ssh -i ~/.ssh/proxmox_key root@192.168.11.10
ssh -i ~/.ssh/proxmox_key root@192.168.11.11
Troubleshooting
sshpass Not Installed
# Ubuntu/Debian
sudo apt-get install sshpass
# RHEL/CentOS
sudo yum install sshpass
Password Not Found
Check .env file:
sed -n '45,46p' .env
Should show:
PROXMOX_ROOT_PASS=L@KERS2010
Connection Issues
Test connectivity:
ping -c 3 192.168.11.10
ping -c 3 192.168.11.11
Test SSH manually:
ssh -v root@192.168.11.10
Conclusion
✅ All scripts updated to use sshpass
- Password automatically loaded from
.env - Quick access scripts available
- Connectivity tests use sshpass
- Ready for automated operations
Last Updated: 2025-12-13
Status: ✅ CONFIGURED