[Music]
hi I'm Joel a cloud support engineer
here at the AWS Sydney office sometimes
customers tell me they are looking to
manage user accounts on their Amazon ec2
Linux instances I tell them that every
ec2 Linux instance launches with a
default system user account using the
default user account is adequate for
many applications but some customers
choose to add additional user accounts
so that individuals can have their own
files and workspaces creating user
accounts for new users is much more
secure than granting multiple and
possibly inexperienced users access to
the default ec2 user account because
that account can cause a lot of damage
to a system when used improperly
managing user accounts on your Linux
instances is simple let me walk you
through the process of adding a new user
to the system as well as providing
remote access to the new user first
connect to the Linux instance that you
want to add a new user on in this
example I will be using an instance
launched from an Amazon Linux ami as you
can see I've already connected to the
instance to add a new user to the system
use the sudo adduser command followed by
the name of the user you want to create
I'm adding a user account named Joel to
the system the adduser command adds an
entry in there slash etc' / password
file creates a Joel group and creates a
home directory for the new account in
the slash home directory to provide
remote access to the Joel account will
create a SSH directory in Joel's home
directory and create a file in the
directory named authorized underscore
keys which we will later add the public
key - first let's use sudo su - to
switch to the Joel user so that newly
created files have the proper ownership
note that the prompt now says Joel
instead of the default user ec2 user
showing us that we have switched the
shell session to the new account
to provide remote access to the joel
user let's first create the new key pair
for the joel user so i'm going to the
amazon ec2 console now now that I'm in
the Amazon ec2 console in the navigation
pane under network and security I'm
going to go to key pairs so I'm going to
click on key pairs here
next I'm going to choose create key pair
I'm going to enter a name for the keep
it I'm going to call it Joel
- keep it and then I'm going to choose
create
as my keeper so here you have to
download the private key file to your
computer this is the only chance for you
to save the private key file so do so in
a safe place so here I'm going to choose
save file and hit OK
as you can see that's gone into my
downloads folder
okay now let's go back to our shell
session now that we're back in our shell
session let's use the mkdir command to
create the ssh directory we talked about
earlier
now let's use the chmod command to
change the file permissions of the dot
SSH directory to seven zero zero this
means only the file owner can read/write
or open the directory
now let's use the CD command to change
into the SSH directory and then use the
touch command to create the authorized
underscore keys file we talked about
earlier
let's use the chmod command again to
change the file permissions of the
authorized underscore keys file to six
zero zero this means only the file owner
can read or write to the file
before we edit the authorised underscore
keys file we need to retrieve the public
key for the key pair
so as you can see I've opened up a new
tab in terminal and I'm going to use the
chmod command with four zero zero to set
the permissions of my private key file
so that only I can read it
now that the permissions are correct
let's retrieve the public key for the
keypad because I'm on Mac I'm going to
use the SSH - key gen command with the -
y option
into the path for the key and you can
see the public key is displayed on the
screen copy the public key
and in the other terminal session
paste it into the authorized keys file
that's it let's test logging into the
Joel account using the private key
I have my public IP copied so I'm going
to paste that
success running ID shows us the user and
group information for Joel the current
user
thanks for watching and happy cloud
computing from all of us here at AWS
[Music]