Import Key pair to AWS And Change key pair on running EC2 instance
Import key pair and attach to EC2 instance
1. Generate the public-key1 and private-key1 using puttygen
2. save public-key1 and private-key1 in local pc
3. Import public-key1 pair to aws
4. Create new EC2 instance with imported public-key1
5. connect to EC2 instance using private-key1
Generate a new key pair and update directly to ec2-user
1. Generate the public-key2 and private-key2 using puttygen
2. save public-key2 and private-key2 in local pc
3. open public-key2 using notepad copy the key
4. login as ec2-user and cp .ssh/autorized_keys .ssh/autorized_keys.old
5. vi .ssh/autorized_keys and replace the existing key with new public-key2
6. to save the file hit Esc :wq!
7. connect to EC2 instance using private-key2 success
8. connect to EC2 instance using private-key1 failure
![](https://s2.save4k.ru/pic/-RkqQ-gCYik/mqdefault.jpg)