#!/bin/bash # wget https://git.technozone.com.au/vijay/Scripts/raw/branch/main/sftp_transfer -O sftp_transfer.sh && chmod +x sftp_transfer.sh && ./sftp_transfer.sh && rm sftp_transfer.sh # Function to display the menu show_menu() { echo "==============================" echo " SFTP Transfer Menu " echo "==============================" echo "1. Zip a folder" echo "2. Transfer zipped file to remote server" echo "3. Exit" echo "==============================" } # Function to zip a folder zip_folder() { read -p "Enter the folder path to zip: " folder_path read -p "Enter the name for the zipped file (without .zip): " zip_name if [ -d "$folder_path" ]; then zip -r "${zip_name}.zip" "$folder_path" echo "Folder zipped successfully as ${zip_name}.zip" else echo "Error: Directory does not exist." fi } # Function to list available zip files list_zip_files() { echo "Available zip files:" ls *.zip 2>/dev/null } # Function to transfer the zipped file to a remote server transfer_file() { read -p "Enter the remote server username: " username read -p "Enter the remote server address: " server_address read -p "Enter the remote directory to upload the file: " remote_dir read -sp "Enter the password for the remote server: " password echo # List available zip files list_zip_files # Prompt user to select a zip file read -p "Enter the name of the zipped file to transfer (with .zip): " zip_name if [ -f "$zip_name" ]; then # Use sshpass to provide the password for SFTP sshpass -p "$password" sftp -v "${username}@${server_address}" <