#!/bin/bash # 🔍 NETGESCON - VERIFICA PRE-MIGRAZIONE # Creato: 19/07/2025 - Test connessione e preparazione echo "🔍 === NETGESCON - VERIFICA PRE-MIGRAZIONE ===" echo "📅 $(date '+%Y-%m-%d %H:%M:%S')" echo "" TARGET_SERVER="192.168.0.200" TARGET_USER="michele" echo "📋 Test connessione a VM target: $TARGET_USER@$TARGET_SERVER" echo "" # Test connessione base echo "🌐 Test 1: Connessione SSH..." if ssh -o ConnectTimeout=10 -o BatchMode=yes "$TARGET_USER@$TARGET_SERVER" "echo 'SSH OK'" 2>/dev/null; then echo " ✅ SSH con chiavi funziona" else echo " ⚠️ SSH richiede password (normale)" if ssh -o ConnectTimeout=10 "$TARGET_USER@$TARGET_SERVER" "echo 'SSH con password OK'"; then echo " ✅ SSH con password funziona" else echo " ❌ SSH non funziona - verificare rete/credenziali" exit 1 fi fi # Test sistema target echo "" echo "📊 Test 2: Informazioni sistema target..." ssh "$TARGET_USER@$TARGET_SERVER" << 'EOF' echo " Sistema: $(lsb_release -d 2>/dev/null | cut -f2 || uname -s)" echo " Kernel: $(uname -r)" echo " Architettura: $(uname -m)" echo " Uptime: $(uptime | cut -d',' -f1)" echo " Spazio root: $(df -h / | tail -1 | awk '{print $4}') liberi" echo " RAM libera: $(free -h | grep Mem | awk '{print $7}')" echo " Utente: $(whoami)" echo " Home: $HOME" EOF # Test permessi sudo echo "" echo "🔐 Test 3: Permessi sudo..." if ssh "$TARGET_USER@$TARGET_SERVER" "sudo -n true" 2>/dev/null; then echo " ✅ Sudo senza password configurato" else echo " ⚠️ Sudo richiede password (normale per sicurezza)" fi # Test dipendenze base echo "" echo "📦 Test 4: Dipendenze presenti..." ssh "$TARGET_USER@$TARGET_SERVER" << 'EOF' echo -n " Git: " if command -v git &> /dev/null; then echo "✅ $(git --version | cut -d' ' -f3)" else echo "❌ Non installato" fi echo -n " Curl: " if command -v curl &> /dev/null; then echo "✅ Presente" else echo "❌ Non installato" fi echo -n " Docker: " if command -v docker &> /dev/null; then echo "✅ $(docker --version | cut -d' ' -f3 | tr -d ',')" else echo "❌ Non installato" fi echo -n " Apache: " if command -v apache2 &> /dev/null; then echo "✅ $(apache2 -v | head -1 | cut -d' ' -f3)" else echo "❌ Non installato" fi echo -n " PHP: " if command -v php &> /dev/null; then echo "✅ $(php --version | head -1 | cut -d' ' -f2)" else echo "❌ Non installato" fi EOF # Test porte disponibili echo "" echo "🌐 Test 5: Porte disponibili..." ssh "$TARGET_USER@$TARGET_SERVER" << 'EOF' echo " Porte in ascolto:" ss -tlnp | grep -E ":(80|3000|3306|22)" | while read line; do port=$(echo $line | awk '{print $4}' | cut -d':' -f2) echo " - Porta $port: occupata" done # Test porte libere importanti for port in 80 3000 3306; do if ! ss -tln | grep -q ":$port "; then echo " - Porta $port: ✅ libera" fi done EOF echo "" echo "📊 === RIEPILOGO VERIFICA ===" echo "✅ Connessione SSH verificata" echo "✅ Sistema target accessibile" echo "✅ Informazioni raccolte" echo "" echo "📋 Pronto per migrazione!" echo " Eseguire: ./docs/03-scripts-automazione/migrate-to-vm-master.sh" echo ""