Logged in using Private Key but denied permission for home directory with Lightsail instance

0

Hello Forum;

Question: Can someone tell me why I cannot access my home folder after logging in with my ftp programs?

I am using:

  • the username as follows: ec2-user
  • the Lightsail Static IP address
  • the private key I downloaded from the Lightsail Instances -> Connect tab

FileZilla logs in fine but the server won't let me access the home directory.

The Notepad++ program does the same as FileZilla. It logs in but won't let me access the home directory.

Logs in fine using ec2-user for the username, static IP, and private key. FileZilla logs onto server using ec2-user, static IP, and private key

Access is denied when I click to enter home directory. Access denied when I try to enter home directory

FileZilla Site Manager FileZilla Site Manager

I have looked through the questions in this forum for an answer. I have found answers for similar issues with the EC2 instances; but have not found an answer for the issue that I am having with accessing the server with my Lightsail instance.

I was thinking that I may not have the permissions set correctly with Lightsail -> Networking -> Firewall settings. I have tried to find a proper Firewall setting that would allow access but have had no success.

I am using cPanel. I have looked through the Security settings with cPanel but have not found a setting that would help with my problem.

I would appreciate if someone could help me with my problem.

Thank you in advance.

1 Answer
1
Accepted Answer

This can happen if you (the ec2-user) do not have read permisson on /home.

The following would have been done as root:

[root@ip-172-31-46-162 ~]# cd /home
[root@ip-172-31-46-162 home]# ls -las
total 0
0 drwxr-xr-x.  3 root     root      22 May 16 00:31 .
0 dr-xr-xr-x. 18 root     root     237 May  1 19:03 ..
0 drwx------.  3 ec2-user ec2-user  74 May 16 00:31 ec2-user
[root@ip-172-31-46-162 home]# chmod o-r .
[root@ip-172-31-46-162 home]# ls -las
total 0
0 drwxr-x--x.  3 root     root      22 May 16 00:31 .
0 dr-xr-xr-x. 18 root     root     237 May  1 19:03 ..
0 drwx------.  3 ec2-user ec2-user  74 May 16 00:31 ec2-user
[root@ip-172-31-46-162 home]#

Now as ec2-user you can still login but cannot display the contents of the parent directory:

[ec2-user@ip-172-31-46-162 ~]$ pwd
/home/ec2-user
[ec2-user@ip-172-31-46-162 ~]$ ls -las
total 12
0 drwx------. 3 ec2-user ec2-user  74 May 16 00:31 .
0 drwxr-x--x. 3 root     root      22 May 16 00:31 ..
4 -rw-r--r--. 1 ec2-user ec2-user  18 Jan 28 22:29 .bash_logout
4 -rw-r--r--. 1 ec2-user ec2-user 141 Jan 28 22:29 .bash_profile
4 -rw-r--r--. 1 ec2-user ec2-user 492 Jan 28 22:29 .bashrc
0 drwx------. 2 ec2-user ec2-user  48 May 16 00:35 .ssh
[ec2-user@ip-172-31-46-162 ~]$ cd ..
[ec2-user@ip-172-31-46-162 home]$ ls -las
ls: cannot open directory '.': Permission denied
[ec2-user@ip-172-31-46-162 home]$

If the above is the same as on your host here, SSH in as ec2-user, sudo su - to root and chmod o+r /home, and see if that makes a difference.

(NB you must have execite permssion on /home in order for you to be able to traverse through it to your home directory, which from the screenshots we can see you're able to do. And if you didn't have this you couldn't authenticate in the first place with your SSH public key in ~/.ssh).

profile picture
EXPERT
Steve_M
answered a year ago
  • RWC;

    Thank you for responding to my question.

    I got the issue figured out, finally. This problem has had me stymied for a few days.

    I changed the permissions in the home directory and sub-directories. I changed the permissions to 755. I am now able to connect with FileZilla and Notepad++.

    Thanks again.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions