Add User to EC instance with /home directory


[ec2-user@ip-172-30-1-107 conf.d]$ adduser paul
-bash: /usr/sbin/adduser: Permission denied
[ec2-user@ip-172-30-1-107 conf.d]$ sudo adduser paulpend
[ec2-user@ip-172-30-1-107 conf.d]$ cd /home
[ec2-user@ip-172-30-1-107 home]$ ls
ec2-user paulpend
[ec2-user@ip-172-30-1-107 home]$ ls -la
total 16
drwxr-xr-x 4 root root 4096 Feb 17 23:21 .
dr-xr-xr-x 25 root root 4096 Feb 16 19:22 ..
drwx------ 4 ec2-user ec2-user 4096 Feb 17 07:35 ec2-user
drwx------ 2 paulpend paulpend 4096 Feb 17 23:21 paulpend
[ec2-user@ip-172-30-1-107 home]$

 

Now this user needs access in someway

[ec2-user@ip-172-30-1-107 home]$ cd ec2-user
[ec2-user@ip-172-30-1-107 ~]$ ls
[ec2-user@ip-172-30-1-107 ~]$ ls -la
total 36
drwx—— 4 ec2-user ec2-user 4096 Feb 17 07:35 .
drwxr-xr-x 4 root root 4096 Feb 17 23:21 ..
-rw——- 1 ec2-user ec2-user 1262 Feb 17 07:35 .bash_history
-rw-r–r– 1 ec2-user ec2-user 18 Aug 30 19:00 .bash_logout
-rw-r–r– 1 ec2-user ec2-user 193 Aug 30 19:00 .bash_profile
-rw-r–r– 1 ec2-user ec2-user 124 Aug 30 19:00 .bashrc
drwx—— 2 ec2-user ec2-user 4096 Feb 16 19:22 .ssh
drwxr-xr-x 2 ec2-user ec2-user 4096 Feb 17 02:46 .vim
-rw——- 1 ec2-user ec2-user 996 Feb 17 07:35 .viminfo
[ec2-user@ip-172-30-1-107 ~]$ cd .ssh
[ec2-user@ip-172-30-1-107 .ssh]$ ls
authorized_keys

ec2-user etin with keys

 

http://www.linfo.org/su.html

 

If I try to go into this new users home folder I get permissioned denied.

Why?

Because I am currently ec2-user

 


[ec2-user@ip-172-30-1-107 home]$ cd paulpend
-bash: cd: paulpend: Permission denied
[ec2-user@ip-172-30-1-107 home]$ whoami
ec2-user

I can use the su command to change my login session to paulpend

 

However paulpend has no password


[ec2-user@ip-172-30-1-107 home]$ su paulpend
Password:
su: Authentication failure

So what the fuck should I do?

Well, since ec2-user is a sudoer then I can sudo and act on behalf of root who can do whatever they want.

[ec2-user@ip-172-30-1-107 home]$ sudo su paulpend
[paulpend@ip-172-30-1-107 home]$

Or alternatively I could get paulpend a password if I wanted

[paulpend@ip-172-30-1-107 home]$ pwd
/home
[paulpend@ip-172-30-1-107 home]$ ls -la
total 16
drwxr-xr-x 4 root root 4096 Feb 17 23:21 .
dr-xr-xr-x 25 root root 4096 Feb 16 19:22 ..
drwx------ 4 ec2-user ec2-user 4096 Feb 17 07:35 ec2-user
drwx------ 2 paulpend paulpend 4096 Feb 17 23:21 paulpend
[paulpend@ip-172-30-1-107 home]$ cd paulpend
[paulpend@ip-172-30-1-107 ~]$ ls -la
total 20
drwx------ 2 paulpend paulpend 4096 Feb 17 23:21 .
drwxr-xr-x 4 root root 4096 Feb 17 23:21 ..
-rw-r--r-- 1 paulpend paulpend 18 Aug 30 19:00 .bash_logout
-rw-r--r-- 1 paulpend paulpend 193 Aug 30 19:00 .bash_profile
-rw-r--r-- 1 paulpend paulpend 124 Aug 30 19:00 .bashrc
[paulpend@ip-172-30-1-107 ~]$ touch index.html
[paulpend@ip-172-30-1-107 ~]$ ls -la
total 20
drwx------ 2 paulpend paulpend 4096 Feb 17 23:37 .
drwxr-xr-x 4 root root 4096 Feb 17 23:21 ..
-rw-r--r-- 1 paulpend paulpend 18 Aug 30 19:00 .bash_logout
-rw-r--r-- 1 paulpend paulpend 193 Aug 30 19:00 .bash_profile
-rw-r--r-- 1 paulpend paulpend 124 Aug 30 19:00 .bashrc
-rw-rw-r-- 1 paulpend paulpend 0 Feb 17 23:37 index.html
[paulpend@ip-172-30-1-107 ~]$ nano index.html
[paulpend@ip-172-30-1-107 ~]$ ls -la
total 24
drwx------ 2 paulpend paulpend 4096 Feb 17 23:37 .
drwxr-xr-x 4 root root 4096 Feb 17 23:21 ..
-rw-r--r-- 1 paulpend paulpend 18 Aug 30 19:00 .bash_logout
-rw-r--r-- 1 paulpend paulpend 193 Aug 30 19:00 .bash_profile
-rw-r--r-- 1 paulpend paulpend 124 Aug 30 19:00 .bashrc
-rw-rw-r-- 1 paulpend paulpend 28 Feb 17 23:37 index.html
[paulpend@ip-172-30-1-107 ~]$

 

Now I’ve made an index.html file and I need Apache to server it.

Let’s try to make a virtual host.

Leave a Reply

Your email address will not be published. Required fields are marked *