This repository contains Bash scripts designed to simplify managing AWS EC2 instances. It includes scripts for connecting to EC2 via SSH and transferring files between a local machine and an EC2 instance using SCP.
A Bash script to establish an SSH connection to an EC2 instance, with error checking for IP address format, key pair, and connection success.
./connect-ec2.shThe script will prompt you to:
- Enter your public IP address.
- Provide the path to your key pair file (default:
knust). - Enter the username for the EC2 instance (default:
ubuntu).
./connect-ec2.shYou will be guided through entering the necessary details. The script ensures the key pair file has the correct permissions (chmod 400) and checks for connection success.
- Validates IP address format.
- Ensures the key pair file exists and applies correct permissions.
- Checks for connection success and provides appropriate feedback.
This script facilitates secure file transfers between your local machine and an EC2 instance using SCP. It supports both uploading files to and downloading files from the EC2 instance, with input validation at each step.
./transfer-files-ec2.shThe script will prompt you to:
- Enter the public IP address of your EC2 instance.
- Provide the path to your key pair file (default:
knust). - Enter the username for the EC2 instance (default:
ubuntu). - Choose between uploading or downloading a file.
- Provide the local file path and the remote file path on the EC2 instance.
For uploading a file:
./transfer-files-ec2.shFor downloading a file:
./transfer-files-ec2.shYou will be prompted for details as the script guides you through the process of transferring files between your local machine and the EC2 instance.
- Validates IP address and file paths.
- Allows for both file uploads and downloads.
- Provides detailed error messages and success feedback.
- Ensure you have proper access to the EC2 instance and the required key pair.
- You must have
SSHandSCPinstalled on your machine.
This project is licensed under the MIT License.