<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Baraa Mohamed</title>
    <description>The latest articles on DEV Community by Baraa Mohamed (@baraamohamed2311).</description>
    <link>https://dev.to/baraamohamed2311</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2416916%2F45b57434-c688-46ed-af54-4f6607f5cd11.png</url>
      <title>DEV Community: Baraa Mohamed</title>
      <link>https://dev.to/baraamohamed2311</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/baraamohamed2311"/>
    <language>en</language>
    <item>
      <title>Saving Plan vs Reserved Plan</title>
      <dc:creator>Baraa Mohamed</dc:creator>
      <pubDate>Tue, 11 Aug 2026 15:42:51 +0000</pubDate>
      <link>https://dev.to/baraamohamed2311/saving-plan-vs-reserved-plan-1dkg</link>
      <guid>https://dev.to/baraamohamed2311/saving-plan-vs-reserved-plan-1dkg</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgiclqrvx5s12so24fytw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgiclqrvx5s12so24fytw.jpg" alt=" " width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're not picturing the difference — say you have one m5.large server on on-demand, you'd pay $840.96 over a year compared to:&lt;/p&gt;

&lt;p&gt;If you go Reserved, the price could drop to $235.47&lt;br&gt;
If Savings Plan, it could get down to $285.93&lt;/p&gt;

&lt;p&gt;But these numbers obviously aren't fixed, they depend on when you reserve, the region, and so on.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reserved Instances (RIs)?
&lt;/h3&gt;

&lt;p&gt;Allow you to reserve EC2 capacity for 1 or 3 years in exchange for a discount of up to 72% compared to On-Demand pricing.&lt;/p&gt;

&lt;p&gt;🔹 Types of Reserved Instances:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Standard RIs:&lt;/strong&gt; The highest discount, but you have to be committed to a specific instance type, meaning you're confident about the load that'll be on that instance for the whole long period you're reserving it for. And if you want to get rid of them, you'll have to list them for sale on the RIs Marketplace&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Convertible RIs:&lt;/strong&gt; Lower discount than the one above, but gives you the chance to switch between instance types, on condition that the final cost ends up equal to or higher than what was originally agreed&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What Are AWS Savings Plans?&lt;/p&gt;

&lt;p&gt;More flexible alternative to Reserved Instances, offering up to 72% savings in exchange for a commitment to a minimum spend per hour for 1 or 3 years.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔹 Types of Savings Plans:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compute Savings Plans:&lt;/strong&gt; Let the discount apply across more than one service — Lambda, EC2, Fargate&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;EC2 Instance Savings Plans&lt;/strong&gt; Lock you into a specific family and region, but you can change the instance type within the same family freely&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we notice, we'll find that both options let you change the instance type you're using, so why do we say the savings plan is more flexible?&lt;/p&gt;

&lt;p&gt;Reserved is basically a promise you make to AWS, so even if the plan type was Convertible RIs, even if you wanted to change the server type you'd have to send an exchange request that's manual and wait for it to get approved so the discount applies to it, otherwise you'll get charged on-demand.&lt;/p&gt;

&lt;p&gt;The Savings Plan is more automatic because it focuses on the amount you spend more than what you're actually using, so if you change the instance or the service, e.g. from ec2 to Fargate, it'll look at your spending from, say, the last hour, and start checking what's supported, and if the discount applies to it, it'll save you more.&lt;/p&gt;

&lt;p&gt;What do you pick?&lt;/p&gt;

&lt;p&gt;✅ Reserved Instances if:&lt;/p&gt;

&lt;p&gt;✔️ Your load is predictable during the plan period so you won't need to change the instance much.&lt;br&gt;
✔️ You'll only use EC2 instances&lt;/p&gt;

&lt;p&gt;✅ Savings Plans if:&lt;/p&gt;

&lt;p&gt;✔️ You'll be using something from EC2, Fargate, and Lambda&lt;br&gt;
✔️ You need the discount to focus on your spending, not what you're actually using&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(1) Question:&lt;/strong&gt; Since Compute Savings Plans has a more flexible option, does that make it better than Reserved?&lt;/p&gt;

&lt;p&gt;No, because yes you have flexibility, but you might not need it if you know your load is constant or that you don't need anything beyond EC2 — in that case RIs would be more suitable and the discount reaches 72% instead of 66%&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(2) Question:&lt;/strong&gt; So if I don't need other services and I have two options with the same 72% discount, which are EC2 Instance Savings Plans and RIs, what do I choose based on?&lt;/p&gt;

&lt;p&gt;The idea of the Savings Plan is that you become flexible, yes, but if there's a specific server type you know you need in a specific zone that might not be available later — say if the servers were stopped for a while and you started them again, or you're doing scaling —&lt;/p&gt;

&lt;p&gt;Then the most suitable option is Zonal-Reserved, because it'll always keep the capacity you requested set aside for you until you need it&lt;/p&gt;

&lt;p&gt;🤍 &lt;strong&gt;I would appreciate If we connect together on LinkedIn :&lt;/strong&gt; &lt;a href="//linkedin.com/in/baraa-mohamed-4b2034284"&gt;Visit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>saas</category>
      <category>devops</category>
    </item>
    <item>
      <title>Identity-based Policy, Service Control Policy, Resource-based Policy, Permissions Boundary 😵‍💫</title>
      <dc:creator>Baraa Mohamed</dc:creator>
      <pubDate>Tue, 11 Aug 2026 15:38:53 +0000</pubDate>
      <link>https://dev.to/baraamohamed2311/identity-based-policy-service-control-policy-resource-based-policy-permissions-boundary-4egb</link>
      <guid>https://dev.to/baraamohamed2311/identity-based-policy-service-control-policy-resource-based-policy-permissions-boundary-4egb</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh24tn3l0lytaijobadmt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh24tn3l0lytaijobadmt.jpg" alt=" " width="800" height="579"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Identity-based Policy, Service Control Policy, Resource-based Policy, Permissions Boundary 😵‍💫&lt;/p&gt;

&lt;p&gt;All of these are terms related to permissions you deal with on AWS, but what's the difference between them?&lt;/p&gt;

&lt;p&gt;First, they're split into two types:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Granting Permission:&lt;/strong&gt; Identity-based Policy, Resource-based Policy&lt;br&gt;
&lt;strong&gt;Guardrail Permissions:&lt;/strong&gt; Service Control Policy, Permissions Boundary&lt;/p&gt;

&lt;p&gt;💰 Think of it like an ATM machine: the Guardrail sets the overall allowed permissions for the ATM (the upper ceiling), and the Granting is what actually gives you the right to execute the action.&lt;/p&gt;

&lt;h3&gt;
  
  
  Identity-based Policy
&lt;/h3&gt;

&lt;p&gt;Gets attached to the user or role or group itself, and defines what they're allowed to do on which service.&lt;/p&gt;

&lt;p&gt;Real example: a user with a policy that allows them s3:GetObject and s3:PutObject on any bucket.&lt;/p&gt;

&lt;p&gt;💰 Like when you open a bank account, the bank activates certain services on your card: (you're allowed to withdraw, transfer, and pay online).&lt;/p&gt;

&lt;h3&gt;
  
  
  Service Control Policy (SCP)
&lt;/h3&gt;

&lt;p&gt;Works at the AWS Organizations level (Org / OU / Account) and defines the maximum possible permissions — even if the identity policy allows it, if the SCP blocks the action it won't execute.&lt;/p&gt;

&lt;p&gt;Real example: a company has an Organization with Dev and Prod accounts, and has an SCP on the Prod OU that blocks anyone (even admins) from doing s3:DeleteBucket or leaving the Organization, to protect the data from being deleted by mistake.&lt;/p&gt;

&lt;p&gt;💰 Like the bank preventing any branch from allowing withdrawal in any currency other than Egyptian pounds, no matter what permissions the employee doing the withdrawal has.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resource-based Policy
&lt;/h3&gt;

&lt;p&gt;Gets placed on the resource itself (not the user), and must have a "Principal" specifying who's allowed to interact with it. Supported in S3, SNS, SQS, Lambda, KMS, and others.&lt;/p&gt;

&lt;p&gt;Real example: a bucket called global-bucket with a policy that allows a specific group of accounts to read the data&lt;/p&gt;

&lt;p&gt;💰 Like a specific ATM machine that's only linked to VIP accounts, and anyone else with a regular card won't be able to withdraw from it even if they have withdrawal permission in general.&lt;/p&gt;

&lt;h3&gt;
  
  
  Permissions Boundary
&lt;/h3&gt;

&lt;p&gt;Defines the maximum possible permissions for a specific IAM user or role (i.e. individually, not across multiple accounts like SCP).&lt;/p&gt;

&lt;p&gt;Real example: a DevOps team gives every developer permission to create new IAM roles for their projects, but sets a Permissions Boundary on them that prevents them from granting themselves or any role they create admin-level permissions like iam:* or organizations:*, so no one can do privilege escalation on themselves.&lt;/p&gt;

&lt;p&gt;💰 Like a father giving his son a card linked to his own, but setting limits on the spending that can be withdrawn from the card, and it can't be exceeded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: for any action to go through, it must not be denied in any of the intersecting policies, because a Deny from any single one of them is enough to stop the action ❌.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;🤍&lt;strong&gt;I would appreciate If we connect together on LinkedIn :&lt;/strong&gt; &lt;a href="//linkedin.com/in/baraa-mohamed-4b2034284"&gt;Visit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>security</category>
      <category>cloud</category>
      <category>iam</category>
    </item>
    <item>
      <title>RBAC &amp; Admission Controllers</title>
      <dc:creator>Baraa Mohamed</dc:creator>
      <pubDate>Tue, 11 Aug 2026 15:30:52 +0000</pubDate>
      <link>https://dev.to/baraamohamed2311/rbac-admission-controllers-3f51</link>
      <guid>https://dev.to/baraamohamed2311/rbac-admission-controllers-3f51</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvu30skn71yxx0m8zqqfa.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvu30skn71yxx0m8zqqfa.gif" alt=" " width="760" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now you've set up your cluster and everything's working fine — what's stopping the junior devops guy from taking down production completely innocently 😇&lt;/p&gt;

&lt;p&gt;This is where a Kubernetes feature comes in that adds a security layer to define the types of actions that can be taken in your cluster&lt;/p&gt;

&lt;p&gt;So basically, what's the difference between RBAC and Admission Controllers&lt;/p&gt;

&lt;h2&gt;
  
  
  1️⃣ RBAC:
&lt;/h2&gt;

&lt;p&gt;You use it to define the types of commands each role is allowed to use, and it has two types based on scope&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1️⃣ Namespace scoped "kind: Role"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example you could block any create/delete command for the junior devops in the production namespace&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2️⃣ Cluster scoped "kind: ClusterRole"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example you can define permissions at the whole Cluster level, not a specific Namespace — block the junior from deleting any Node at the cluster level.&lt;/p&gt;

&lt;p&gt;How do you confirm this?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl auth can-i &amp;lt;&lt;span class="nb"&gt;command&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &amp;lt;resource&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl auth can-i delete namespaces
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2️⃣ Admission Controller:
&lt;/h2&gt;

&lt;p&gt;Adds more details that you can't express in RBAC, which is why it's a layer that comes after it&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Restrict to a specific Registry: block any Pod from being created if its Image is coming from outside the company's Private Registry&lt;/p&gt;

&lt;p&gt;Force the team to set Resource Limits: reject any Deployment that doesn't specify cpu and memory (Requests &amp;amp; Limits).&lt;/p&gt;

&lt;p&gt;Prevent using the latest tag: reject any Container filled in with a Tag like image:nginx:latest.&lt;/p&gt;

&lt;p&gt;📌 You might need to install an add-on like Kyverno or OPA Gatekeeper&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of my own implementations:&lt;/strong&gt; &lt;a href="https://github.com/BaraaMohamed2311/Graduation-Project/tree/master/Kubernetes/cluster-security" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🤍** I would appreciate If we connect together on LinkedIn :** &lt;a href="//linkedin.com/in/baraa-mohamed-4b2034284"&gt;Visit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>security</category>
      <category>devops</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Rename Any Text Across Multiple Files with One Command! 🔍🔄</title>
      <dc:creator>Baraa Mohamed</dc:creator>
      <pubDate>Tue, 10 Dec 2024 14:58:24 +0000</pubDate>
      <link>https://dev.to/baraamohamed2311/rename-functions-variables-or-text-across-multiple-files-with-one-command-3o5k</link>
      <guid>https://dev.to/baraamohamed2311/rename-functions-variables-or-text-across-multiple-files-with-one-command-3o5k</guid>
      <description>&lt;p&gt;I’ve come into situation before while I was building Employee Management System Full-stack website, Where I needed to change name of variable and some functions but the issue was that they are used in many files.&lt;/p&gt;

&lt;p&gt;For them being used in multiple files it wasn’t logically to manually detect them in each file and replace them.&lt;/p&gt;

&lt;p&gt;One solution I found is using Linux commands :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;find&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./node_modules&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;prune&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;exec&lt;/span&gt; &lt;span class="nx"&gt;sed&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;s/old_text/new_text/g&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;find&lt;/code&gt; : is used to find certain files, here we use it to find all &lt;code&gt;.js&lt;/code&gt; files&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;\( \)&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;: the backslashes are used for Linux to execute what’s inside instead of giving an error&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-path&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;: To specify certain path which we will prune&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-prune&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;: To ignore certain paths from this command’s execution&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-o&lt;/code&gt; : Is or option so if left side is executed ( which is ignoring &lt;code&gt;“node_modules”&lt;/code&gt;&lt;/strong&gt; ) &lt;strong&gt;we skip executing rest of command after &lt;code&gt;-o&lt;/code&gt; .&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-name "*.js"&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;: to find any file that is &lt;code&gt;.js&lt;/code&gt; when it’s not &lt;code&gt;“node_modules”&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;folder&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-exec sed&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;: To execute replacing command which is sed.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-i&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;: to actually change text in file.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;{}&lt;/code&gt; is a placeholder for the file or directory name that the &lt;code&gt;find&lt;/code&gt; command matches.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;+&lt;/code&gt; : Called batch mode tells &lt;code&gt;find&lt;/code&gt; to pass multiple matched files to the command in batches instead of running the command once per file.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Usage Example
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;I have 2 &lt;code&gt;test.js&lt;/code&gt; files one of them is in&lt;/strong&gt; &lt;strong&gt;&lt;code&gt;“node_modules”&lt;/code&gt; folder, Both of them has text “baraa mohamed”.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So we execute following command.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;find&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./node_modules&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;prune&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;exec&lt;/span&gt; &lt;span class="nx"&gt;sed&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;s/baraa/XBaraaX/g&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;After execution result of &lt;code&gt;test.js&lt;/code&gt; outside&lt;/strong&gt; &lt;strong&gt;&lt;code&gt;“node_modules”&lt;/code&gt; :&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;XBaraaX&lt;/span&gt; &lt;span class="nx"&gt;mohamed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Also after executing we find &lt;code&gt;test.js&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;inside &lt;code&gt;“node_modules”&lt;/code&gt; :&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;baraa&lt;/span&gt; &lt;span class="nx"&gt;mohamed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see it did not change as we pruned ( ignored ) the whole &lt;strong&gt;&lt;code&gt;“node_modules”&lt;/code&gt; directory.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;🤍 I'd love to connect with you on LinkedIn—let's grow our network and share ideas! &lt;a href="https://www.linkedin.com/in/baraa-mohamed-4b2034284?lipi=urn%3Ali%3Apage%3Ad_flagship3_profile_view_base_contact_details%3BAIVW4ELGQHSFtLJUIpn8Yg%3D%3D" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>linux</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>NAT Gateway VS Internet Gateway? 🤔</title>
      <dc:creator>Baraa Mohamed</dc:creator>
      <pubDate>Tue, 10 Dec 2024 08:00:38 +0000</pubDate>
      <link>https://dev.to/baraamohamed2311/what-is-the-difference-between-nat-gateway-internet-gateway-320l</link>
      <guid>https://dev.to/baraamohamed2311/what-is-the-difference-between-nat-gateway-internet-gateway-320l</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjyd3q459ewijjd4y6by3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjyd3q459ewijjd4y6by3.gif" alt=" " width="720" height="645"&gt;&lt;/a&gt;&lt;br&gt;
This is usually the very first question that pops up when designing AWS networking. 🤔 Let’s break it down using this architecture:&lt;/p&gt;

&lt;p&gt;🟣 Internet Gateway (IGW)&lt;br&gt;
Think of the Internet Gateway as your VPC’s front door to the public internet. It handles both inbound and outbound traffic, acting as the target in your route tables for public subnet traffic.&lt;/p&gt;

&lt;p&gt;Scope &amp;amp; Limits: You attach one IGW per VPC.&lt;/p&gt;

&lt;p&gt;💰 Cost: The gateway itself is completely free—you only pay for standard AWS outbound data transfer.&lt;/p&gt;

&lt;p&gt;🟣 NAT Gateway&lt;br&gt;
What if you have instances in a private subnet that need internet access to pull security patches or dependencies—without exposing them to external threats? That’s where the NAT Gateway comes in. It translates private IP addresses to allow outbound-only connectivity.&lt;/p&gt;

&lt;p&gt;💡 Key Distinction: "Outbound-only" means connections must originate from inside your private subnet. While return traffic from your requests is allowed back in, external users on the internet can never initiate a new connection directly to your private instances through a NAT Gateway. (If users need to access your app via a browser, that inbound flow is handled by an Application Load Balancer not the NAT Gateway).&lt;/p&gt;

&lt;p&gt;Placement &amp;amp; Scope: A NAT Gateway must be placed inside a public subnet so it can route through the IGW. So, NAT Gateways are zonal resources—for high availability across Availability Zones, you should deploy one in a public subnet within each AZ.&lt;/p&gt;

&lt;p&gt;💰 Cost: AWS charges for NAT Gateways per hour (for provisioning) plus a per-GB data processing fee on all data transferred through it.&lt;/p&gt;

&lt;p&gt;Why Use It:&lt;/p&gt;

&lt;p&gt;Enhanced Security Posture: Keeps workloads isolated while maintaining outbound access.&lt;/p&gt;

&lt;p&gt;Allows private application servers to run apt update, fetch dependencies, or call third-party APIs safely.&lt;/p&gt;

&lt;p&gt;🟣 How to Access Your Private Instances (Bastion Host)&lt;br&gt;
Since private servers aren't directly reachable from the internet, you'll use a Bastion Host (jump box) pattern to connect:&lt;/p&gt;

&lt;p&gt;SSH into your public instance inside the public subnet (the Bastion server).&lt;/p&gt;

&lt;p&gt;From the Bastion, initiate a second SSH connection into your target instance inside the private subnet (Private App).&lt;/p&gt;

&lt;p&gt;Because both subnets are inside the same VPC, AWS routes this traffic internally via the local VPC router.&lt;/p&gt;

&lt;p&gt;The NAT Gateway is completely bypassed. The request never leaves the VPC, never touches the internet, and never hits the NAT Gateway.&lt;/p&gt;

&lt;p&gt;To Implement that ssh access approach please check that blog: &lt;a href="https://dev.to/baraamohamed2311/methods-of-accessing-ec2-in-private-subnet-1gn0"&gt;visit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Quick Summary&lt;br&gt;
Internet Gateway (IGW): Inbound &amp;amp; Outbound | 1 per VPC | Free gateway&lt;/p&gt;

&lt;p&gt;NAT Gateway: Outbound-only | Zonal (1 per AZ for HA) | Paid hourly + per GB&lt;/p&gt;

&lt;p&gt;Let's connect on &lt;a href="//www.linkedin.com/in/baraa-mohamed-4b2034284"&gt;LinkedIn &lt;/a&gt;to share cloud engineering insights and grow our networks!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>awschallenge</category>
      <category>awsbigdata</category>
      <category>cloud</category>
    </item>
    <item>
      <title>SSH Tunnel: Forwarding Traffic between hosts</title>
      <dc:creator>Baraa Mohamed</dc:creator>
      <pubDate>Tue, 26 Nov 2024 14:25:29 +0000</pubDate>
      <link>https://dev.to/baraamohamed2311/ssh-tunnel-forwarding-traffic-between-hosts-4id2</link>
      <guid>https://dev.to/baraamohamed2311/ssh-tunnel-forwarding-traffic-between-hosts-4id2</guid>
      <description>&lt;p&gt;In cloud environments, you might encounter scenarios where you need to forward traffic securely between hosts. SSH tunneling, also known as port forwarding, is a technique that allows you to create a secure communication tunnel between two hosts over specific ports.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is SSH Tunneling?
&lt;/h3&gt;

&lt;p&gt;SSH tunneling enables secure access to remote services that are not directly accessible. For instance, you can access a private service on a cloud server through a public host. This approach helps maintain security by keeping sensitive services private.&lt;/p&gt;




&lt;h3&gt;
  
  
  Example: Accessing Jenkins Dashboard on AWS
&lt;/h3&gt;

&lt;p&gt;Suppose you have Jenkins running on an EC2 instance in AWS, and you want to access its dashboard on port &lt;strong&gt;8080&lt;/strong&gt;. Using SSH tunneling, you can securely forward traffic from your local machine to the Jenkins instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pre-requisites:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Ensure the Jenkins EC2 instance allows &lt;strong&gt;TCP&lt;/strong&gt; traffic on port &lt;strong&gt;8080&lt;/strong&gt; and HTTP traffic in its security group.&lt;/li&gt;
&lt;li&gt;Have the access key for the Jenkins EC2 instance.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Command to Create the Tunnel:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-i&lt;/span&gt; &amp;lt;access-key&amp;gt; &lt;span class="nt"&gt;-L&lt;/span&gt; &amp;lt;your-host-port&amp;gt;:&amp;lt;Jenkins-ip&amp;gt;:&amp;lt;Jenkins-port&amp;gt; &amp;lt;public-Jenkins-instance&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"myKey.pem"&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt; 4040:localhost:8080 ubuntu@ec2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation of Flags:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;i&lt;/code&gt;: Includes the access key file required for authentication.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;L&lt;/code&gt;: Specifies the local port (&lt;code&gt;4040&lt;/code&gt;), remote host (&lt;code&gt;localhost&lt;/code&gt; or the private IP of Jenkins), and remote port (&lt;code&gt;8080&lt;/code&gt;) for the tunnel.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;localhost&lt;/code&gt;: Refers to the Jenkins instance. SSH forwards traffic to port 8080 on the Jenkins EC2 instance.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Accessing Jenkins Locally
&lt;/h3&gt;

&lt;p&gt;After running the command, open your browser and navigate to &lt;a href="http://localhost:4040" rel="noopener noreferrer"&gt;http://localhost:4040&lt;/a&gt;. You should see the Jenkins dashboard, as traffic on port 4040 of your machine is securely forwarded to port 8080 on the EC2 instance.&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;By leveraging SSH tunneling, you can securely access remote services like Jenkins dashboards without exposing them to the public internet. This technique is versatile and applicable to many cloud-based workflows.&lt;/p&gt;

&lt;p&gt;🤍 I'd love to connect with you on LinkedIn—let's grow our network and share ideas! &lt;a href="https://www.linkedin.com/in/baraa-mohamed-4b2034284?lipi=urn%3Ali%3Apage%3Ad_flagship3_profile_view_base_contact_details%3BAIVW4ELGQHSFtLJUIpn8Yg%3D%3D" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>linux</category>
      <category>ubuntu</category>
      <category>aws</category>
    </item>
    <item>
      <title>SSH-Agent: Simplifying SSH Key Management</title>
      <dc:creator>Baraa Mohamed</dc:creator>
      <pubDate>Tue, 26 Nov 2024 14:24:22 +0000</pubDate>
      <link>https://dev.to/baraamohamed2311/ssh-agent-simplifying-ssh-key-management-3j2a</link>
      <guid>https://dev.to/baraamohamed2311/ssh-agent-simplifying-ssh-key-management-3j2a</guid>
      <description>&lt;p&gt;&lt;strong&gt;SSH-Agent&lt;/strong&gt; is one of the tools in the SSH suite that simplifies managing access keys for secure server connections.&lt;/p&gt;

&lt;p&gt;You can think of the SSH-Agent as a "bag" that holds your access keys, allowing you to access servers conveniently through other servers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Starting the SSH-Agent
&lt;/h3&gt;

&lt;p&gt;Begin by running the following command to start the SSH-Agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This initializes the agent — think of it as "opening the bag."&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding Access Keys
&lt;/h3&gt;

&lt;p&gt;Next, add your access keys to the agent. Each key represents a credential for accessing different servers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-add &amp;lt;file1&amp;gt;
ssh-add &amp;lt;file2&amp;gt;
ssh-add &amp;lt;file3&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is like placing keys into your bag.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connecting to Servers
&lt;/h3&gt;

&lt;p&gt;To connect to a server using a specific access key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &amp;lt;access-key1&amp;gt; &lt;span class="nt"&gt;-A&lt;/span&gt; &amp;lt;server1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;v&lt;/code&gt;: Verbose mode — displays loading steps in the terminal (optional).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;i&lt;/code&gt;: Specifies the access key file for authentication.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;A&lt;/code&gt;: Forwards the SSH-Agent, allowing access to additional servers without re-entering keys.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Accessing Additional Servers
&lt;/h3&gt;

&lt;p&gt;If you need to SSH from &lt;code&gt;server1&lt;/code&gt; to &lt;code&gt;server2&lt;/code&gt;, simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &amp;lt;access-key2&amp;gt; &amp;lt;server2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the &lt;code&gt;-A&lt;/code&gt; flag only if you plan to SSH further from &lt;code&gt;server2&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Best Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;ssh-add&lt;/code&gt; to securely load private keys into the agent.&lt;/li&gt;
&lt;li&gt;Forward the SSH-Agent (&lt;code&gt;A&lt;/code&gt;) only when necessary to minimize security risks.&lt;/li&gt;
&lt;li&gt;Regularly clean up your agent by running &lt;code&gt;ssh-add -D&lt;/code&gt; to remove all keys after your session.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;By using SSH-Agent, you can simplify secure server access while reducing repetitive key management tasks.&lt;/p&gt;

&lt;p&gt;🤍 I'd love to connect with you on LinkedIn—let's grow our network and share ideas! &lt;a href="https://www.linkedin.com/in/baraa-mohamed-4b2034284?lipi=urn%3Ali%3Apage%3Ad_flagship3_profile_view_base_contact_details%3BAIVW4ELGQHSFtLJUIpn8Yg%3D%3D" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>aws</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Accessing EC2 In Private Subnet | Bastion | VPC | AWS</title>
      <dc:creator>Baraa Mohamed</dc:creator>
      <pubDate>Tue, 26 Nov 2024 14:20:55 +0000</pubDate>
      <link>https://dev.to/baraamohamed2311/methods-of-accessing-ec2-in-private-subnet-1gn0</link>
      <guid>https://dev.to/baraamohamed2311/methods-of-accessing-ec2-in-private-subnet-1gn0</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1m0hcygkpjgdr295pun6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1m0hcygkpjgdr295pun6.png" alt="Bastion - VPC - AWS - Archeticture" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessing Private EC2 Instances in AWS: A Guide
&lt;/h2&gt;

&lt;p&gt;Cloud architectures commonly use public and private subnets to balance accessibility and security. Public subnets host resources like bastion hosts or load balancers, while private subnets house sensitive workloads such as application servers. This setup ensures a secure environment, as private EC2 instances are only accessible through specific configurations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two Approaches to Access Private EC2 Instances
&lt;/h3&gt;

&lt;p&gt;Depending on your requirements, you can access an EC2 instance in a private subnet through one of two methods: SSH access or traffic forwarding.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Method 1: SSH Access to a Private EC2&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This method is ideal for performing configurations or debugging directly on the private EC2 instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Start the SSH-Agent to manage your private keys:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the private EC2 key to the agent:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-add &amp;lt;file-key-of-private-app&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Connect to the bastion host in the public subnet, forwarding the SSH-Agent:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &amp;lt;file-key-of-bastion&amp;gt; &lt;span class="nt"&gt;-A&lt;/span&gt; &amp;lt;public-instance&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From the bastion host, SSH into the private EC2:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &amp;lt;file-key-of-private-app&amp;gt; &amp;lt;private-instance&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By forwarding the agent (&lt;code&gt;-A&lt;/code&gt;), you securely authenticate to the private instance without transferring your private keys.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Method 2: Port Forwarding&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you need to access a service (e.g., Jenkins) running on the private EC2, port forwarding allows you to securely forward traffic through the bastion host.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: Forwarding Jenkins Dashboard
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Start the SSH-Agent and add the private key:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
ssh-add &amp;lt;file-key-of-private-app&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Forward traffic from port 8080 on the private EC2 to port 4040 on your local machine:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &amp;lt;file-key-of-bastion&amp;gt; &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt; 4040:&amp;lt;ip-of-private-jenkins-ec2&amp;gt;:8080 &amp;lt;public-instance&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open &lt;a href="http://localhost:4040/" rel="noopener noreferrer"&gt;http://localhost:4040&lt;/a&gt; in your browser to access the Jenkins dashboard.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Note:
&lt;/h3&gt;

&lt;p&gt;To retrieve the Jenkins setup password, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo cat&lt;/span&gt; /var/lib/jenkins/secrets/initialAdminPassword
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach avoids exposing Jenkins to the internet, improving security.&lt;/p&gt;




&lt;h3&gt;
  
  
  Best Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use SSH-Agent to securely store keys during your session.&lt;/li&gt;
&lt;li&gt;Enable agent forwarding (&lt;code&gt;A&lt;/code&gt;) only when necessary to minimize security risks.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Clean up your SSH session by removing keys after use:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-add &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;With these methods, you can securely access private EC2 instances while maintaining a robust and secure cloud architecture.&lt;/p&gt;

&lt;p&gt;🤍 I'd love to connect with you on LinkedIn—let's grow our network and share ideas! &lt;a href="https://www.linkedin.com/in/baraa-mohamed-4b2034284?lipi=urn%3Ali%3Apage%3Ad_flagship3_profile_view_base_contact_details%3BAIVW4ELGQHSFtLJUIpn8Yg%3D%3D" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>linux</category>
      <category>awschallenge</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
