Moving a virtual machine from the cloud to your local server is totally possible — and easier than it looks if you follow the right process.
In this guide, you’ll learn how to:
- Export an EC2 instance as an AMI
- Download it as a VMDK file
- Import it into Proxmox
- Fix SSH and networking issues
Architecture Overview
AWS EC2 → AMI → Export → S3 → Download VMDK → Proxmox → Import → Run VM Phase 1: Export from AWS
Step 1: Stop the EC2 Instance
Go to EC2 → Instances
Select your instance
Click Stop
Stopping ensures filesystem consistency.
Step 2: Create AMI
Actions → Image and Templates → Create Image
Wait until the status becomes Available
Step 3: Create VM Export Role (IAM)
Use the following trust policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "vmie.amazonaws.com" },
"Action": "sts:AssumeRole"
}
]
}
Step 4: Attach Permissions to Role
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject",
"s3:GetBucketAcl"
],
"Resource": [
"arn:aws:s3:::YOUR_BUCKET",
"arn:aws:s3:::YOUR_BUCKET/*"
]
},
{
"Effect": "Allow",
"Action": [
"ec2:CopySnapshot",
"ec2:CreateSnapshot",
"ec2:DeleteSnapshot",
"ec2:Describe*",
"ec2:RegisterImage"
],
"Resource": "*"
}
]
}
Step 5: Update S3 Bucket Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"
},
"Action": [
"s3:PutObject",
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::YOUR_BUCKET",
"arn:aws:s3:::YOUR_BUCKET/*"
]
}
]
}
Step 6: Give Export Permissions (Important)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:ExportImage",
"ec2:DescribeExportImageTasks"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"
}
]
}
Step 7: Export AMI
aws ec2 export-image \
--image-id ami-xxxx \
--disk-image-format VMDK \
--s3-export-location S3Bucket=YOUR_BUCKET,S3Prefix=exports/
Step 8: Check Export Status
aws ec2 describe-export-image-tasks Step 9: Download VMDK
aws s3 cp s3://YOUR_BUCKET/exports/file.vmdk Phase 2: Import into Proxmox
Step 10: Upload File
- Log in to Proxmox Web UI
- Go to Node → local → ISO Images
- Click Upload
Before uploading, rename the file from .vmdk to .iso (for example: export-ami-xxxx.vmdk → export-ami-xxxx.iso) because Proxmox ISO storage only accepts ISO files.
- Upload the renamed file
cd /var/lib/vz/template/iso
mv file.iso file.vmdk Step 12: Create VM (Without Disk)
Create a new VM
Skip disk creation
Step 13: Import Disk
qm importdisk 109 file.vmdk local-lvm Step 14: Attach Disk
Go to VM → Hardware
Select Unused Disk
Attach using SCSI or VirtIO
Step 15: Set Boot Order
Set the imported disk as the first boot device
Step 16: Start VM
Start the VM and open the console.
Phase 3: Fix Ubuntu Login
Step 17–22: Reset Password Using GRUB
Reboot the VM
Press ESC or Shift during boot
Select Advanced options
Choose recovery mode
Open root shell
Run:
mount -o remount,rw /
passwd ubuntu
reboot -f Enable SSH Password Login
nano /etc/ssh/sshd_config Change:
PasswordAuthentication yes Restart SSH:
systemctl restart ssh Phase 4: Configure Networking (Cloud-Init)
Step 23: Add Cloud-Init Drive
VM → Hardware → Add → CloudInit Drive
Step 24–27: Configure Cloud-Init
Set:
Username
Password
SSH key (optional)
Network options:
DHCP:
ip=dhcp Static IP:
ip=192.168.1.120/24,gw=192.168.1.1 Step 28: Apply Configuration
qm cloudinit update 109 Step 29: Verify IP Address
ip a Step 30: Connect via SSH
ssh ubuntu@VM_IP Phase 5: Fix EC2 SSH Issues
Remove AWS-specific configurations:
rm /usr/lib/systemd/system/ssh.service.d/ec2-instance-connect.conf
rm -f /etc/ssh/sshd_config.d/*.conf
systemctl daemon-reload
systemctl restart ssh Final Result
You have successfully:
- Exported an EC2 instance as an AMI
- Converted it to a VMDK file
- Imported it into Proxmox
- Fixed login and SSH issues
- Configured networking
- Enabled remote access
Conclusion
Migrating an AWS EC2 instance to Proxmox is a practical way to move workloads from the cloud to your local infrastructure. By exporting the AMI, converting it to a VMDK file, and importing it into Proxmox, you can recreate your cloud environment with minimal changes.
The key steps are straightforward: prepare the instance, configure IAM permissions correctly, export the image, and then import and configure it in Proxmox. Post-migration fixes such as resetting the password, enabling SSH access, and configuring networking with Cloud-Init ensure the system works as expected.
This approach is especially useful for reducing cloud costs, maintaining local backups, building hybrid environments, or setting up development and testing systems. With the right process, you can reliably run your AWS workloads on your own infrastructure.