Hi gurus.
I have an ec2 instance already with a Key-pair, is there a way I can have a second Key-pair for a user to use SSH tunnel to this ec2 that already exists?
Thanks gurus
(29-09-2022, 12:33 AM)fborges5555 Wrote: [ -> ]Hi gurus.
I have an ec2 instance already with a Key-pair, is there a way I can have a second Key-pair for a user to use SSH tunnel to this ec2 that already exists?
Thanks gurus
Yes you can.
For each user account, the ssh key is stored in the folder ~/.ssh (i.e. /home/<user>/.ssh). The key itself is in a file called 'authorized_keys'.
You can generate a new key pair on your local machine with either the ssh-keygen command line utility or even an application like putty. Then upload the public key pair as 'authorized_keys'. Remember that this should be done under the respective user folder, not on root. After this, everytime a user attempts to connect via SSH, it should accept their ssh key for logging in. This is assuming that there is no configuration in the /etc/ssh/sshd_config file that explicitly denies a user from being able to login via ssh with key.
If you're trying to just add another keypair for the standard user like ec2-user or root, you just need to append the new key to the existing authorized_keys file in that user ssh folder.