From 52778038a486305d9123702cfd05d5f9e88a5b4f Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Fri, 16 Jun 2023 13:28:46 +0530 Subject: [PATCH 1/6] modified: projects/bash_networking_security/vpc.sh --- projects/bash_networking_security/vpc.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/bash_networking_security/vpc.sh b/projects/bash_networking_security/vpc.sh index 951abba..d79d95e 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="34.224.93.183" +PRIVATE_INSTANCE_ID="10.0.1.116" \ No newline at end of file From 2212596db63173de3cae12c6b2b8f1e9dcc4c4e5 Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Fri, 16 Jun 2023 13:32:32 +0530 Subject: [PATCH 2/6] modified: projects/bash_networking_security/SOLUTION --- projects/bash_networking_security/SOLUTION | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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) From 2834eb6c46f6877209da4648b5cb1c6edadc886b Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Fri, 16 Jun 2023 13:34:23 +0530 Subject: [PATCH 3/6] modified: projects/bash_networking_security/bastion_connect.sh --- .../bastion_connect.sh | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/projects/bash_networking_security/bastion_connect.sh b/projects/bash_networking_security/bastion_connect.sh index a9bf588..e6fce60 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 awsKeyPair.pem ubuntu@"$PRIVATE_IP" + else + # Run a command on the private instance + ssh -i "$KEY_PATH" ubuntu@"$BASTION_IP" ssh -tt -i awsKeyPair.pem ubuntu@"$PRIVATE_IP" "$COMMAND" + fi +fi \ No newline at end of file From 0096bfcb5ec24a28e0247679a09f16c3a6471adc Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Fri, 16 Jun 2023 15:15:31 +0530 Subject: [PATCH 4/6] modified: projects/bash_networking_security/bastion_connect.sh --- projects/bash_networking_security/bastion_connect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/bash_networking_security/bastion_connect.sh b/projects/bash_networking_security/bastion_connect.sh index e6fce60..28238ca 100644 --- a/projects/bash_networking_security/bastion_connect.sh +++ b/projects/bash_networking_security/bastion_connect.sh @@ -22,9 +22,9 @@ if [ -z "$PRIVATE_IP" ]; then else # Connect to the private instance through the public instance if [ -z "$COMMAND" ]; then - ssh -i "$KEY_PATH" ubuntu@"$BASTION_IP" ssh -tt -i awsKeyPair.pem ubuntu@"$PRIVATE_IP" + 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 awsKeyPair.pem ubuntu@"$PRIVATE_IP" "$COMMAND" + ssh -i "$KEY_PATH" ubuntu@"$BASTION_IP" ssh -tt -i anew_key ubuntu@"$PRIVATE_IP" "$COMMAND" fi fi \ No newline at end of file From 909672dd80387d5beb773501f6fb8394e04094f0 Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Sat, 17 Jun 2023 12:16:06 +0530 Subject: [PATCH 5/6] modified: projects/bash_networking_security/vpc.sh --- projects/bash_networking_security/vpc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/bash_networking_security/vpc.sh b/projects/bash_networking_security/vpc.sh index d79d95e..f704499 100644 --- a/projects/bash_networking_security/vpc.sh +++ b/projects/bash_networking_security/vpc.sh @@ -1,4 +1,4 @@ REGION="us-east-1" VPC_ID="vpc-01dfe779f8f43669a" -PUBLIC_INSTANCE_ID="34.224.93.183" -PRIVATE_INSTANCE_ID="10.0.1.116" \ No newline at end of file +PUBLIC_INSTANCE_ID="i-07acba4579a7dbbc3" +PRIVATE_INSTANCE_ID="i-04ef2bb5caef53905" \ No newline at end of file From cbb00c87e6e71124d765381e8ba176c58b6e27c0 Mon Sep 17 00:00:00 2001 From: i-amit88 <102894134+i-amit88@users.noreply.github.com> Date: Sat, 17 Jun 2023 12:40:41 +0530 Subject: [PATCH 6/6] Update vpc.sh --- projects/bash_networking_security/vpc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/bash_networking_security/vpc.sh b/projects/bash_networking_security/vpc.sh index f704499..61beaca 100644 --- a/projects/bash_networking_security/vpc.sh +++ b/projects/bash_networking_security/vpc.sh @@ -1,4 +1,4 @@ REGION="us-east-1" VPC_ID="vpc-01dfe779f8f43669a" PUBLIC_INSTANCE_ID="i-07acba4579a7dbbc3" -PRIVATE_INSTANCE_ID="i-04ef2bb5caef53905" \ No newline at end of file +PRIVATE_INSTANCE_ID="i-04ef2bb5caef53905"