diff --git a/projects/bash_networking_security/SOLUTION b/projects/bash_networking_security/SOLUTION index 2edfbaf..7db0d22 100644 --- a/projects/bash_networking_security/SOLUTION +++ b/projects/bash_networking_security/SOLUTION @@ -1,16 +1,19 @@ Local DNS Server IP ------------------- - +127.0.0.53 Default gateway IP ------------------- - +10.0.0.1 DHCP IP allocation sys-logs ------------------- - +Jun 9 07:29:19 ip-10-0-0-171 dhclient[346]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x8b932f1f) +Jun 9 07:29:19 ip-10-0-0-171 dhclient[346]: DHCPOFFER of 10.0.0.171 from 10.0.0.1 +Jun 9 07:29:19 ip-10-0-0-171 dhclient[346]: DHCPREQUEST for 10.0.0.171 on eth0 to 255.255.255.255 port 67 (xid=0x1f2f938b) +Jun 9 07:29:19 ip-10-0-0-171 dhclient[346]: DHCPACK of 10.0.0.171 from 10.0.0.1 (xid=0x8b932f1f) diff --git a/projects/bash_networking_security/bastion_connect.sh b/projects/bash_networking_security/bastion_connect.sh index a9bf588..28238ca 100644 --- a/projects/bash_networking_security/bastion_connect.sh +++ b/projects/bash_networking_security/bastion_connect.sh @@ -1 +1,30 @@ #!/bin/bash + +# Check if KEY_PATH environment variable is set +if [ -z "$KEY_PATH" ]; then + echo "KEY_PATH env var is expected" +fi + +# Check if the public instance IP is provided +if [ -z "$1" ]; then + echo "Please provide bastion IP address" + exit 5 +fi + +# Set variables +BASTION_IP=$1 +PRIVATE_IP=$2 +COMMAND=$3 + +# Connect to the public instance +if [ -z "$PRIVATE_IP" ]; then + ssh -i "$KEY_PATH" ubuntu@"$BASTION_IP" +else + # Connect to the private instance through the public instance + if [ -z "$COMMAND" ]; then + ssh -i "$KEY_PATH" ubuntu@"$BASTION_IP" ssh -tt -i new_key ubuntu@"$PRIVATE_IP" + else + # Run a command on the private instance + ssh -i "$KEY_PATH" ubuntu@"$BASTION_IP" ssh -tt -i anew_key ubuntu@"$PRIVATE_IP" "$COMMAND" + fi +fi \ No newline at end of file diff --git a/projects/bash_networking_security/vpc.sh b/projects/bash_networking_security/vpc.sh index 951abba..61beaca 100644 --- a/projects/bash_networking_security/vpc.sh +++ b/projects/bash_networking_security/vpc.sh @@ -1,4 +1,4 @@ -REGION="" -VPC_ID="" -PUBLIC_INSTANCE_ID="" -PRIVATE_INSTANCE_ID="" \ No newline at end of file +REGION="us-east-1" +VPC_ID="vpc-01dfe779f8f43669a" +PUBLIC_INSTANCE_ID="i-07acba4579a7dbbc3" +PRIVATE_INSTANCE_ID="i-04ef2bb5caef53905"