I am logging in my AWS EC2 instance using winscp/putty as root using a .ppk file which has imported-openssh-key.
Earlier it was shared with many ppl, who are all gone, so now I have to change it in such a way that no one else can access it.
I tried to search about it on internet but couldn't find any. Thanks in advance 🙂
Best Answer
You need to change the keys. On your instance use ssh-keygen to do this e.g.
Now you have a public key (/root/.ssh/id_rsa.pub) that needs to be added to the
/root/.ssh/authorized_keys
fileYou'll have to remove the old key from the authorized_keys file later.
Don't log out.
Copy the new private key (/root/.ssh/id_rsa) to your windows machine and use puttygen to import and save it like you did previously.
Check that you can log in using your new keys. If you can then remove the old key from your instance.
Don't log out.
Now check again that you can log in using your new keys
You really shouldn't use the root account in this manner. You should create separate user accounts for everyone that needs access to your system. You should then use sudo to grant them access to the commands they need to do the job. Sudo is part of the base install for most (all ?) Linux distros.