-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ssh_connection.sh
More file actions
executable file
·50 lines (41 loc) · 1.37 KB
/
test_ssh_connection.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Test SSH connectivity to both VMs
# Run this AFTER configuring VMs through GUI
# Load configuration
if [ -f "config.env" ]; then
source config.env
else
echo "Error: config.env file not found. Please copy config.env.example to config.env and update with your values."
exit 1
fi
echo "=== Testing SSH connectivity to VMs ==="
echo ""
# Test different common usernames
test_ssh() {
local ip=$1
local vm_name=$2
echo "Testing SSH to $vm_name ($ip)..."
# Try fallback usernames
for user in $FALLBACK_USERS; do
echo " Trying user: $user"
if ssh -o ConnectTimeout=$SSH_TIMEOUT -o StrictHostKeyChecking=no $user@$ip "echo 'SSH successful with user: $user'" 2>/dev/null; then
echo " ✅ SUCCESS: SSH works with user '$user'"
echo " Update your scripts to use: VM_USER=\"$user\""
return 0
fi
done
echo " ❌ FAILED: Could not connect with any common username"
echo " Please check:"
echo " - VM is running and configured"
echo " - SSH is enabled in the VM"
echo " - User account exists"
return 1
}
test_ssh $VM1_IP "VM1"
echo ""
test_ssh $VM2_IP "VM2"
echo ""
echo "=== Next Steps ==="
echo "1. If SSH works, update the VM_USER variable in setup_vms_for_test.sh"
echo "2. Then run: ./setup_vms_for_test.sh"
echo "3. Finally run: ./run_sync_test.sh"