To add a user account

  1. Use the following adduser command to add the newuser account to the system (with an entry in the /etc/passwd file). This command also creates a group and a home directory for the account.
    [ec2-user ~]$ sudo adduser newuser
  2. Switch to the new account so that newly created files have the proper ownership.
    [ec2-user ~]$ sudo su - newuser 
    [newuser ~]$

    Notice that the prompt changes from ec2-user to newuser to indicate that you have switched the shell session to the new account.

  3. Create a .ssh directory in the newuser home directory and change its file permissions to 700 (only the owner can read, write, or open the directory).
    [newuser ~]$ mkdir .ssh 
    [newuser ~]$ chmod 700 .ssh


    Without these exact file permissions, the user will not be able to log in.

  4. Set password for newly created user
    [root ~]$ passwd newuser
    Changing password for user newuser
    New password: 
    Retype new password: 
    passwd: all authentication tokens updated successfully.
  5. Allow user to login using username and password
    [root ~]$ vim /etc/ssh/sshd_config

    Change PasswordAuthentication and ChallengeResponseAuthentication to yes

    [root ~]$ service sshd restart
    Stopping sshd:                                             [  OK  ]
    Starting sshd:                                             [  OK  ]