Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for How to configure password in Amazon ec2 instance
Anshuman
Anshuman

Posted on

     

How to configure password in Amazon ec2 instance

  • In this tutorial, I have added the configurations required for ec2 user password authentication for AWS ec2 Linux instances.
  • As by default ec2 instance don't have any password .Follow these simple steps to configure password in your linux instance .

Note:- It is not recommended to configure password in cloud instances unless required .Private key-based authentication is always the safest way to access cloud instances.

Step 1: Log in to the linux machine using ssh client of your choice using the private key.

  • For Windows machines, you can use putty for connecting to the instance.Click here to know how to use putty on Windows .

  • If you are using Mac or Linux, you can use the following command to connect to the instance.

ssh-i your-key.pem username@(public-ip-address)
Enter fullscreen modeExit fullscreen mode

Step 2: Enter the following command to open sshd_config file

sudonano /etc/ssh/sshd_config
Enter fullscreen modeExit fullscreen mode

Step 3: Find the line containing “PasswordAuthentication” parameter and change its value from “no” to “yes“

Find the line containing “PasswordAuthentication” parameter and change its value from “no” to “yes“

Step 4: Now press ctrl + x button and then click on Y button to save the changes

Now press ctrl + x button and then click on Y button to save the changes

Step 5: Setup ec2 user password using the “passwd” command along with the username.

You need to enter the password twice. For example, if you want to set up a password for “centos” user, use the following command.

sudopasswd centos
Enter fullscreen modeExit fullscreen mode

In AWS, different ec2 instances have different usernames. Following are the default usernames of some popular ec2 instances.

InstanceUsername
Ubuntuubuntu
Redhat Linuxec2-user
Amazon Linuxec2-user
CentOScentos
Debianadmin or root

Step 6: Now, restart the “sshd” service using the following command.

sudoservice sshd restart
Enter fullscreen modeExit fullscreen mode

Step 7: Once the "sshd" service is restarted successfully , you can log out and log in using the password you set for the user.
For example,

ssh ubuntu@34.10.100.1
Enter fullscreen modeExit fullscreen mode

I hope this "How to configure password in Amazon ec2 instance" article helps. Let me know in the comment section if you face any errors.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I love to explore new tech and build cool stuff with it.I love reading & writing tech blogs whenever I find a not so common solution to a problem that I personally faced.
  • Location
    Banglore
  • Work
    Product Enginner at InstaSafe
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp