Step-1:
Create a new instance with same OS as previous one or create it from AIM made from old instance
Step-2:
Shutdown the old instance and detach the volume
Step-3:
Shutdown new instance Attached the detached volume to new instance and start the instance
Step-4:
Login new instance using ssh console
Run the following commands:
lsblk
df -h
cd mnt
mkdir oldvolume
sudo mount /dev/sda1 mnt/oldvolume
cd mnt/oldvolume/root/.ssh
sudo vi authorized_keys
Now add your public key and save
umount /dev/sda1
sudo shutdown now
Step-5:
Now detach the dev/sda1 volume from new instance and attach to old instance as dev/sda
Step-6:
Reboot old instance from AWS dashboard and login your old instance using ssh console
Note: Your old instance IP will be changed after doing this if no elastic IP