Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

3 Answers

up vote 7 down vote accepted

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.
share|improve this answer
    
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
add comment

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).

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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