Bacancy Bacancy
      • About Company
      • Resources

      About Company

      About Us Leadership Team Customer Reviews Awards & Recognition
      Infrastructure Our Locations Partnership

      Resources

      Press Room Blog Insights
      We are great place to work certified™

      Building and Sustaining High-Trust, High-Performance Culture

      Get Quote
    • Engagement Models

      Hiring Software Developers becomes easier with just a few clicks.

      Software Development Outsourcing

      End-to-end delivery of custom solutions aligned to your roadmap.

      Staff Augmentation

      Scale your in-house team with pre-vetted specialists on demand.

      Dedicated Teams

      Get dedicated engineers who work exclusively on your project.

      • Enterprise Services
      • IT Services
      • Data Analytics
      • Cloud Services
      • AI & ML
      • Platforms

      Enterprise Services

      Digital Transformation Business Process Automation Digital Product Engineering Enterprise App Development Custom Software Development

      IT Services

      Legacy App Modernization DevOps & SRE Full Stack Development AI Testing & QA Automation

      Data Analytics

      Data Visualization & Reporting Data Engineering & Pipelines Data Science & Predictive Analytics Business Intelligence

      Cloud Services

      Cloud Strategy & Consulting Cloud Migration & Modernization Multi Cloud Management

      AI & ML

      AI Development Agentic AI Generative AI Computer Vision Machine Learning & MLOps

      Platforms

      Salesforce SAP ServiceNow Microsoft Dynamics Snowflake
      High-quality, Cost-effective IT Outsourcing

      Schedule a free discovery session to explore your needs and find tailored solutions with no obligation.

      explore all services
    • Industries
      Healthcare Fintech Real Estate
      Logistics Education Retail & Ecommerce
      Let's Grow Together! Get Quote
      • Front End
      • Backend
      • Mobile
      • Databases
      • DevOps & Infra
      • AI & Data Stack
      • Vibe Coding

      Front End

      React.js Next.js Angular Vue.js TypeScript
      Your Very Own UI/UX Architects

      Experience smooth navigation and user-friendly designs with our front-end expertise.

      Hire Frontend Developer

      Backend

      Node.js Python Java Spring Boot Laravel .NET C# Golang FastAPI
      Server Solutions To Change Power Dynamics

      Transform your data into digital experiences with optimized coding standards.

      Hire Backend Developer

      Mobile

      iOS Android Flutter React Native
      Innovating Mobile-Friendly App Solutions

      Create dynamic mobile apps that make your brand stand out from the crowd.

      Hire Mobile App Developer

      Databases

      PostgreSQL MongoDB MySQL Redis Supabase
      Dedicated Talent With Skilled Approach

      Bring your digital visions to life with a hired resource at your convenience.

      Hire Dedicated Developer

      DevOps & Infra

      AWS Azure Google Cloud Docker Kubernetes Terraform
      Redefining Scalable Digital Infrastructures

      Make your data accessible worldwide at will, and leave the stress behind.

      Get Quote

      AI & Data Stack

      OpenAI LangChain LlamaIndex Apache Spark Airflow Tableau PowerBI Databricks
      Guiding Decisions With Data-Driven Insights

      Transition from your gut calls to actionable insights with our rich Data Science expertise.

      Get Quote

      Vibe Coding

      Base44 Claude Code Cursor Lovable Github Copilot
      Your AI-Native Development Team

      Skip the boilerplate. Our vibe coding experts use AI-first tools to go from prompt to product, fast.

      Hire Vibe Coding Developer
  • Case Studies
  • Contact Us
Find a Developer book a 30 min call
      • About Us
      • Leadership Team
      • Customer Reviews
      • Awards & Recognition
      • Infrastructure
      • Our Locations
      • Partnership
      • Press Room
      • Blog
      • Insights
      • Digital Transformation
      • Business Process Automation
      • Digital Product Engineering
      • Enterprise App Development
      • Custom Software Development
      • Legacy App Modernization
      • DevOps & SRE
      • Full Stack Development
      • AI Testing & QA Automation
      • Data Visualization & Reporting
      • Data Engineering & Pipelines
      • Data Science & Predictive Analytics
      • Business Intelligence
      • Cloud Strategy & Consulting
      • Cloud Migration & Modernization
      • Multi Cloud Management
      • AI Development
      • Agentic AI
      • Generative AI
      • Computer Vision
      • Machine Learning & MLOps
      • Salesforce
      • SAP
      • ServiceNow
      • Microsoft Dynamics
      • Snowflake
    • Healthcare
    • Fintech
    • Real Estate
    • Logistics
    • Education
    • Retail & Ecommerce
      • React.js
      • Next.js
      • Angular
      • Vue.js
      • TypeScript
      • Hire Frontend Developer
      • Node.js
      • Python
      • Java
      • Spring Boot
      • Laravel
      • .NET
      • C#
      • Golang
      • FastAPI
      • Hire Backend Developer
      • iOS
      • Android
      • Flutter
      • React Native
      • Hire Mobile App Developer
      • PostgreSQL
      • MongoDB
      • MySQL
      • Redis
      • Supabase
      • Hire Dedicated Developer
      • AWS
      • Azure
      • Google Cloud
      • Docker
      • Kubernetes
      • Terraform
      • Get Quote
      • OpenAI
      • LangChain
      • LlamaIndex
      • Apache Spark
      • Airflow
      • Tableau
      • PowerBI
      • Databricks
      • Get Quote
      • Base44
      • Claude Code
      • Cursor
      • Lovable
      • Github Copilot
      • Hire Vibe Coding Developer
  • Case Studies
  • Contact Us
  • Find a Developer
  • book a 30 min call
How to Connect AWS Instance After Lost .PEM

How to Connect
AWS Instance After Lost .PEM

Last Updated on November 20, 2024 | Written By:

We often use Private Key (*.pem) file to connect with our ec2 instance, it is best practice to store copy of your Private key(*.pem) file for backup, but what if you lost your (*.pem) file, although have root/admin credential for your AWS account still you must need (*.pem) file to connect with particular instance.

Let’s assume you lost your production instance Private key (*.pem) and you have to make some important changes in your instance, and you don’t have any snapshot of your instance EBS, That time it becomes too much frustrating, fortunately we have another way to connect with instance after lost Private-key(*.pem),

How?

As an example the name is ‘production’ and private-key name is ‘production.pem’ and if you lost or deleted this ‘production.pem’, then below are the steps to recreate a lost Private Key (production.pem) file for Amazon Linux EC2 instance (production). Before recreating the private-key (.pem) file, we need to launch a new instance in the same availability-zone (AZ).

‘production’

Prerequisites:

Step 1: Before Starting, we must have to note down the original instance availability zone (us-east-1a), Instance name and id you can find this on EC2 dashboard after selecting your instance.

Step 2: Launch a new instance with same availability zone (AZ) as we note down before you can select Availability Zone (AZ) at 3rd step (Configure Instance) while creating an instance.

Prerequisites

Step 3 : At last while we are launching instance we will see the key-pair section (at last) from there we have an option for creating and downloading a new key pair and then we can launch the instance. Now we have to login with a newly created instance using new key-pair.

Step 4:As we know each instance contain one or more EBS volumes, that is instance storage, you have find out EBS volume of lost private-key instance, for that click on Instance Description and find , ‘ Root device ‘

Prerequisites

Step 5: Now click on EBS ID this will redirect to EBS Volume page and give a name to this EBS volume so you can identify each volumes. Then we have to detach this volume from the original instance (production instance) for that we have to stop instance (left click on instance select Instance state -> click stop).

Step 6: Once production instance is stopped, detach EBS volume (left click on volume and select detach) and attach it to the newly created instance.
Note: If you didn’t find the newly created instance in Attach Instance wizard than something wrong with your Availability Zone (AZ)

Step 7: After Attaching EBS to the newly created instance, now you are able to connect this EBS using newly created instance. For that do log in to newly created instance terminal.

Step 8: After that we have to check whether new EBS is attached successfully or not with new instance you can check by running below command.
lsblk  – This command is used for determining if the volume is partitioned

Prerequisites

Step 9: If you find another disk than EBS is attached successfully, now we have to replace old authorized_eys (production or lost .pem) with new created authorized_keys for that run below commands.

Prerequisites

 1. sudo mkdir /mnt/removery_vol
 2. sudo mount /dev/xvdf1	/mnt/recovery_vol
 3. cp .ssh/authorized_keys /mnt/recovery_vol/home/ubuntu/.ssh/authorized_keys
  • sudo mkdir /mnt/recovery_vol
  • This will create temp recovery directory to mount the volume
  • sudo mount /dev/xvdf1 /mnt/recovery_vol
  • Mount the volume (or partition) at the temporary recovery mount point, using the volume
  • name or device name you identified earlier
  • cp .ssh/authorized_keys /mnt/recovery_vol/home/ubuntu/.ssh/authorized_keys
  • Copy new authorized keys to old EBS volume (old/production EBS)

Step 10: After successfully changes on authorized_keys, detach this volume from new instance and attach it with Production (lost private-key) instance, after attaching now start production instance.

Step 11: Congratulations, now you can connect to this instance using newly created instance Private key (.pem) file.


Expand Your Digital Horizons With Us.

Start a new project or take an existing one to the next level. Get in touch to start small, scale-up, and go Agile.


Or
E-mail us : solutions@bacancy.com

Your Success Is Guaranteed !

Related Articles

Mehul Budasna

March 30, 2026

Cloud

Cloud Migration Automation: What It Is, Why It Matters, and How to Do It Right

By : Mehul Budasna

In this blog, we will discuss what cloud migration automation is, why migrations fail when done manually, and how it...

Read More
Mehul Budasna

February 26, 2026

Cloud

How Cloud Security Audits Strengthen Compliance and Security Across GDPR, HIPAA, and PCI-DSS Standards

By : Mehul Budasna

Read More
Chandresh Patel

December 12, 2025

Cloud

GCP vs AWS vs Azure – Evaluating the Three Big Cloud Platforms

By : Chandresh Patel

GCP vs AWS vs Azure can be confusing, with each platform providing unique advantages and AI capabilities. In this comparison...

Read More

Offices and Development Centers

Bacancy Ahmedabad Ahmedabad

15-16, Times Corporate Park, Thaltej, Ahmedabad, 380059

Bacancy Gandhinagar Gandhinagar

422-A, 4th Floor, Pragya Tower Road 11, Block 15, Zone 1, SEZ-PA Gandhinagar, 382355

Bacancy Hyderabad Hyderabad

Awfis, Level 1, N Heights, Plot No 38, Phase 2, Hitech City Hyderabad, 500081

Bacancy Mumbai Mumbai

18th Floor, Cyberone, opp. CIDCO Exhibition Centre, Sector 30, Vashi, Navi Mumbai, 400703

Bacancy Pune Pune

2nd FloorMarisoft-1, Marigold IT Park, Pune - 411014

Bacancy Bengaluru Bengaluru

Raheja Towers, 26/27, Mahatma Gandhi Rd, East Wing, Craig Park Layout, Ashok Nagar, Bengaluru, 560001

Global Presence

Bacancy New Jersey New Jersey

33 South Wood Ave, Suite 600, Iselin NJ 08830

Bacancy California California

535 Mission St 14th floor, San Francisco, CA 94105

Bacancy Massachusetts Massachusetts

501 Boylston St, Boston, MA 02116

Bacancy Florida Florida

4995 NW, 72nd Avenue, Suite 307, Miami, FL, 33166

Bacancy London London

90 York Wy, London N1 9AG, United Kingdom

Bacancy Ontario Ontario

71 Dawes Road, Brampton, On L6X 5N9, Toronto

Bacancy Australia Australia

351A Hampstead Rd, Northfield SA 5085

Bacancy UAE UAE

One Central 8th and 9th Floor - Trade Centre - Trade Centre 2 - Dubai - United Arab Emirates

Bacancy Sweden Sweden

Junkergatan 4, 126 53 Hagersten

Get in Touch

Great Place to Work

Get in Touch

cal-icon

Looking for expert advice?

Schedule a Expert Call


  • Brochure
  • Quality Assurance
  • Resources
  • Tutorials
  • Customer Reviews
  • Privacy Policy
  • FAQs
  • Press Room
  • Contact Us
  • Sitemap
  • Employee

bacancy google review 4.6
bacancy google review
bacancy clutch review 4.8
bacancy clutch review
bacancy goodfirms review 4.8
bacancy goodfirms review
iso
  • Bacancy Behance
  • Bacancy Pinterest

Copyright © 2026 BACANCY SERVICES PRIVATE LIMITED All rights reserved.