yes, this is possible. Follow the below mentioned steps @Hannah:
- Create a new ssh key pair
- Stop the running instance
- Go to Actions -> Instance Settings -> View/change user data
- Add the following script
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [users-groups, once]
users:
- name: username
ssh-authorized-keys:
- ssh-rsa keypair
- Add your username in the username sections and replace the key pair with the new key pair and click on Save.