To add a user account
- 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
- 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
tonewuser
to indicate that you have switched the shell session to the new account. - Create a
.ssh
directory in thenewuser
home directory and change its file permissions to700
(only the owner can read, write, or open the directory).[newuser ~]$
mkdir .ssh
[newuser ~]$
chmod 700 .ssh
Important
Without these exact file permissions, the user will not be able to log in.
- 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.
- Allow user to login using username and password
[root ~]$ vim /etc/ssh/sshd_config
Change
PasswordAuthentication
andChallengeResponseAuthentication
to yes[root ~]$ service sshd restart Stopping sshd: [ OK ] Starting sshd: [ OK ]