#!/bin/bash

# Variables
SSH_USER="root"  # Change to your SSH username
SSH_HOST="localhost"      # Change to your SSH host (could be an IP or domain)
SSH_KEY="/home/wasif/.ssh/Wasif"  # Path to your SSH private key
SOURCE_FILE="/home2/mumaraone.tar.gz"  # File to copy
DESTINATION_DIR="/home/wasif/public_html/docs/"  # Destination directory

# Check if SSH key exists
if [ ! -f "$SSH_KEY" ]; then
    echo "Error: SSH key not found at $SSH_KEY"
    exit 1
fi

# Check if source file exists
if [ ! -f "$SOURCE_FILE" ]; then
    echo "Error: Source file not found at $SOURCE_FILE"
    exit 1
fi

# Execute the command over SSH to copy the file
ssh -i "$SSH_KEY" -o StrictHostKeyChecking=no "$SSH_USER@$SSH_HOST" "cp $SOURCE_FILE $DESTINATION_DIR"

# Check the result of the SSH command
if [ $? -eq 0 ]; then
    echo "File copied successfully to $DESTINATION_DIR"
else
    echo "Error occurred while copying the file"
    exit 1
fi
