Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
How can I chroot ssh connections?

I want to jail a particular user into a directory (so they can sftp and ssh) using chroot on Debian. How can I do this?

The man page says

Usage: chroot [OPTION] NEWROOT [COMMAND [ARG]...]
  or:  chroot OPTION
Run COMMAND with root directory set to NEWROOT.

  --userspec=USER:GROUP  specify user and group (ID or name) to use
  --groups=G_LIST        specify supplementary groups as g1,g2,..,gN
      --help     display this help and exit
      --version  output version information and exit

I want to jail user "smart" into /home/servers/smart but when I type: chroot --userspec=1001 /home/servers/smart, it says chroot: failed to run command '/bin/bash': No such file or directory

I've googled my brains out and I can't find a single tutorial on the built-in chroot command.

share|improve this question

marked as duplicate by Iain Oct 8 '12 at 10:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
AFAIK if you want to allow user to ssh into that directory you will need at least minimal chroot environment including bash and it's dependencies you can find using ldd /bin/bash –  Hrvoje Špoljar Oct 8 '12 at 10:43
    
If you are using a sufficiently new version of sshd then you the second answer in the dupe will help you. –  Iain Oct 8 '12 at 10:51

1 Answer 1

up vote 1 down vote accepted

This is basically a duplicate of: How can I chroot ssh connections?

A chroot does not apply per user, but per process. -- So it has to be called/activated by the sshd or the user's login shell.

Limiting an SFTP login is quite simple in newer OpenSSH versions. For interactive shell logins it is always more difficult, because all allowed programs have to be accessible inside the jail.

share|improve this answer
    
Thanks. can you point or show how toset up a jailed ftp directory? –  Kevin Duke Oct 8 '12 at 10:51
    
With sshd's internal-sftp and ChrootDirectory config options. -- See undeadly.org/cgi?action=article&sid=20080220110039 or it.toolbox.com/blogs/unix-sysadmin/… –  mschuett Oct 8 '12 at 11:00

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