Home > Software design >  Adduser to ssh into Aws Ec2
Adduser to ssh into Aws Ec2

Time:11-08

I am testing to setup a Git on the Server (Ec2 - Linux Amazon). All things are going fine but I did one thing that I can not reproduce and I would like to understand.

I am following this tutorial for Git on the Server https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server

I created 4 users to test and created their ssh key on server. (User Git) On /home/git/.ssh/authorized_keys file, I added the other 3 users public key (id_rsa.pub) to allow them push.

I use this commands to create users and ssh keys. I checked all permissions on /home/username/.ssh folders (700) and authorized_keys (600) file.

$ sudo adduser git
$ sudo su - git
$ cd
$ mkdir .ssh && chmod 700 .ssh
$ touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys

I created ssh key on ec2 using the following commands

$ ssh-keygen -o
or
$ ssh-keygen -t rsa -m PEM

My question is, why one user I can ssh into ec2 using public-key (id_rsa.pub)? The other 3 users I only can ssh into ec2 using private key (id_rsa)

I am ssh into ec2

$ ssh -i username.pem [email protected]

Thanks

CodePudding user response:

The other 3 users I only can ssh into ec2 using private key (id_rsa)

Double-check that using, with one of the three users:

ssh -Tv [email protected]

You will see exactly what ssh is using for its connection.

"They are effectively interchangeable.": John alluded to the fact:

  • Related