With AWS Systems Manager
, you can easily connect to EC2 without key pairs, but there are some issues with this method.
For example, if you have multiple developers working on the same EC2, each person needs their own connection environment. It’s a hassle to distribute key pairs to everyone. You can use AWS Systems Manager
or EC2 Instance Connect
, but some people may not have those environments set up. The best is to create an environment where you can just SSH in directly.
So, let’s actually do it!
This is for EC2 with Amazon Linux.
useradd username
passwd username
# Change the password for 'username'.
# New password:
Once that’s done, next:
Most likely, your sshd_config
looks like this, so uncomment and enable PasswordAuthentication yes
and PermitRootLogin yes
.
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes # Uncomment this
#PermitEmptyPasswords no
PasswordAuthentication no # Comment this out
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin yes # Uncomment this
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
After that, just restart the sshd service.
systemctl restart sshd.service
Try to connect to make sure it works.
ssh username@public_IP
And that’s it. Just give each person the initial password, and once they connect, they can change it to something only they know.