From f3c39fe5f94fa4cb434d2496310aef990c33e6de Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Thu, 2 May 2024 02:11:08 -0400 Subject: [PATCH] testing --- scripts/github-vagrant.sh | 40 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/scripts/github-vagrant.sh b/scripts/github-vagrant.sh index c13189b..79337a2 100755 --- a/scripts/github-vagrant.sh +++ b/scripts/github-vagrant.sh @@ -18,34 +18,24 @@ sleep $INITIAL_SLEEP # Loop until timeout or breaks while [[ $ELAPSED -lt $TIMEOUT ]]; do + VAGRANT_SSH_CONFIG=$(mktemp) + vagrant ssh-config > "$VAGRANT_SSH_CONFIG" + set -x + cat "$VAGRANT_SSH_CONFIG" + set +x vagrant status - PRIVATE_KEY="$(vagrant ssh-config | grep -vE 'IdentityFile.*\.rsa$' | awk '{print $2}')" - HOST_IP="$(vagrant ssh-config | grep HostName | awk '{print $2}')" - echo "$DEBUG_ID Checking SSH connection availability..." - echo "$DEBUG_ID Private Key: $PRIVATE_KEY" - echo "$DEBUG_ID Host IP: $HOST_IP" - echo "$DEBUG_ID Running nmap to check open ports..." - - # Check if SSH is open - nmap -p 22 "$HOST_IP" | grep "22/tcp open" && SSH_AVAILABLE=1 || SSH_AVAILABLE=0 - if [[ $SSH_AVAILABLE -eq 1 ]]; then - echo "$DEBUG_ID SSH port is open, attempting connection..." - set -x - ssh -vvv -i "$PRIVATE_KEY" \ - -o UserKnownHostsFile=/dev/null \ - -o StrictHostKeyChecking=no \ - -o IdentitiesOnly=yes \ - -o PreferredAuthentications=publickey \ - -o PubkeyAuthentication=yes \ - -o PasswordAuthentication=no \ - -o KbdInteractiveAuthentication=no \ - vagrant@"$HOST_IP" cat /etc/os-release && break || echo "$DEBUG_ID SSH connection failed, retrying..." - set +x - else - echo "$DEBUG_ID SSH port not open, retrying in $SLEEP_DURATION seconds..." - fi + #echo "$DEBUG_ID Checking SSH connection availability..." + #echo "$DEBUG_ID Private Key: $PRIVATE_KEY" + #echo "$DEBUG_ID Host IP: $HOST_IP" + #echo "$DEBUG_ID Running nmap to check open ports..." + #if [[ $SSH_AVAILABLE -eq 1 ]]; then + echo "$DEBUG_ID SSH port is open, attempting connection..." + set -x + ssh -vvv -F "$VAGRANT_SSH_CONFIG" cat /etc/os-release && break || echo "$DEBUG_ID SSH connection failed, retrying..." + set +x + echo "$DEBUG_ID SSH port not open, retrying in $SLEEP_DURATION seconds..." # Sleep and start again sleep $SLEEP_DURATION ((ELAPSED+=SLEEP_DURATION))