Reputation: 1973
I think I deleted serverside key pair by and now am getting:
Using username "ubuntu".
Server refused our key
I am running a Amazon EC2 server for my customer. How do I restore access to the server?
Upvotes: 0
Views: 351
Reputation: 269490
While you are unable to login to the Amazon EC2 instance, do not panic. All your data is safe!
The instance will need a new keypair loaded into the /users/ubuntu/.ssh/authorized_users
file.
This can be done in two ways:
Method 1: Create a new instance
This method makes an AMI (Amazon Machine Image) of your boot volume and launches a new Amazon EC2 instance from that image. This will trigger the same mechanism that is used to install a key when your instance was initially launched.
The boot process will recognize that it is running on a new Amazon EC2 instance (with a different InstanceId
) and will copy your nominated keypair to the authorized_users
file. You can then login.
Method 2: Copy a keypair to the disk
This method involves attaching the disk to another instance, copying the keypair, then booting it again.
/users/ubuntu/.ssh/authorized_users
fileThis is similar to the rather dated document: How to Recover an Unreachable Linux Instance
Upvotes: 2
Reputation: 276
You can stop (not terminated) the server and make an image from it.
Then you can start a new server based on the image you just made. When you create the new server, you can create a new key pair.
Finally, you can log in the newly created server and use it as usual.
Upvotes: 0