1

A question arose in a group discussion: Can directory listing be disabled for sftp while still retaining read and write access?

We are using openssh on ubuntu server 11.02 if that helps.

2
  • Why not remove directory search permissions? (chmod a-x <dirname>?) – Mikel Jul 25 '12 at 19:23
  • @Mikel, but then you can also not cd any more. – Nils Jul 25 '12 at 19:29
7

Remove Read access.

  • Read access on a directory means that you can see a listing of files within that directory.
  • Execute (X) access means you can cd into the directory or traverse it
  • Write access means that you are able to add or change items within the directory.
1
  • Thanks! Read access was the solution. For interested reader, the command to remove read access from all users is chmod -r folder_name. – Candide Jul 26 '12 at 14:25
0

I do not think so.

I found nothing in the sshd_config man-page that gives a hint about restricting sftp-commands (like the restricitons you can impose on some ftp-daemons).

I have not tested this, but perhaps you can alias the ls command to something that does nothing in ssh-context (so either in .sshrc or via forced-command).

0

I just recently set up a chroot sftp system, and as I was testing, I noticed that a chrooted user with a shell of /bin/false was not able to executer ls without getting kicked out. The sshd_config is also using internal-sftp-server.

I haven't had time to investigate it yet, but I suspect that internal-sftp-server is trying to spawn a sub-shell, and is being denied, since the user's shell is /bin/false. It's just a theory.

FWIW, my user's home directory is root:root 755.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.