Debug ssh
This commit is contained in:
@ -26,13 +26,55 @@ jobs:
|
||||
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
echo "🔧 Setting up SSH configuration..."
|
||||
mkdir -p ~/.ssh
|
||||
|
||||
# Debug: Check if secret exists and has content
|
||||
if [ -z "${{ secrets.DEPLOY_SSH_KEY }}" ]; then
|
||||
echo "❌ DEPLOY_SSH_KEY secret is empty or not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ SSH key secret found"
|
||||
|
||||
# Write the private key
|
||||
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
|
||||
# Get your server's IP (replace with your actual IP)
|
||||
SERVER_IP="192.168.4.56" # Change this to your server's IP
|
||||
ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts
|
||||
# Debug: Verify key file was created
|
||||
if [ ! -f ~/.ssh/deploy_key ]; then
|
||||
echo "❌ Failed to create SSH key file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ SSH key file created"
|
||||
|
||||
# Verify key format
|
||||
if ! ssh-keygen -l -f ~/.ssh/deploy_key; then
|
||||
echo "❌ SSH key appears to be malformed"
|
||||
echo "Key file contents (first few lines):"
|
||||
head -3 ~/.ssh/deploy_key
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ SSH key format is valid"
|
||||
|
||||
# Set server IP and scan for host keys
|
||||
SERVER_IP="192.168.4.56"
|
||||
echo "🔍 Scanning for SSH host keys on $SERVER_IP..."
|
||||
|
||||
# Add error handling for ssh-keyscan
|
||||
if ! ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts 2>/dev/null; then
|
||||
echo "❌ Failed to get SSH host keys from $SERVER_IP"
|
||||
echo "Trying alternative approach..."
|
||||
ssh-keyscan $SERVER_IP >> ~/.ssh/known_hosts 2>/dev/null || {
|
||||
echo "⚠️ ssh-keyscan failed, adding StrictHostKeyChecking=no to SSH commands"
|
||||
}
|
||||
else
|
||||
echo "✅ SSH host keys retrieved successfully"
|
||||
fi
|
||||
|
||||
echo "✅ SSH setup completed"
|
||||
|
||||
- name: Deploy website
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user