I am trying to create some users with Amazon Linux 2 using adduser command but not able to create ssh files for login for those users.
If someone can help me out with the steps it would be really helpful
I am trying to create some users with Amazon Linux 2 using adduser command but not able to create ssh files for login for those users.
If someone can help me out with the steps it would be really helpful
This is standard Linux. It is actually unrelated to the fact that you are using an Amazon EC2 instance.
In a typical organisation, users should generate their own keypairs and then provide the public half to the SysAdmins so they can put it in the ~/.ssh/authorized_keys
file. This way, even the SysAdmins don't have the private half of the keypair.
See: How to use ssh-keygen to generate a new SSH key
Alternatively, users can generate a keypair in the Amazon EC2 console. The public keypair will be retained by AWS for launching future instances and the private keypair will be provided as a downloaded .pem file.
They can extract the public key from a private key with:
ssh-keygen -y -f key.pem > key.pub