Mac OS X Lion上的SSH ChrootDirectory(不是服务器版本)

我试图在我的MacBook Pro上设置一个远程用户帐户,该帐户被chrooted到/chroot/tmux 。 我已经按照这里列出的步骤( http://thefragens.com/blog/2011/12/chrootd-sftp-on-mac-os-x-server/ ),但是当我尝试login(在我的本地networking):

 ssh [email protected] 

…我立即closures连接:

 ❯ ssh [email protected] Password: Connection to 10.0.1.140 closed by remote host. Connection to 10.0.1.140 closed. 

/etc/sshd_config删除这行允许我很好地login,但是我的tmux用户不再是chrooted:

 Match User tmux # ... ChrootDirectory /chroot/tmux # removing this allows me to login 

我需要做些什么才能使这个工作?


当我尝试从客户端用ssh -vv [email protected]login时,这是密码提示后得到的:

 debug2: input_userauth_info_req debug2: input_userauth_info_req: num_prompts 0 debug1: Authentication succeeded (keyboard-interactive). Authenticated to 10.0.1.140 ([10.0.1.140]:22). debug1: channel 0: new [client-session] debug2: channel 0: send open debug1: Requesting [email protected] debug1: Entering interactive session. debug1: channel 0: free: client-session, nchannels 1 Connection to 10.0.1.140 closed by remote host. Connection to 10.0.1.140 closed. Transferred: sent 1872, received 1880 bytes, in 0.0 seconds Bytes per second: sent 100689.1, received 101119.4 debug1: Exit status -1 

令人鼓舞的是,Mac的控制台报告了这一点:

 6/15/12 9:57:42.679 AM sshd: fatal: bad ownership or modes for chroot directory "/chroot/tmux" 

我目前的目录权限:

 ~ ❯ ls -al /chroot/tmux total 8 drwxr-xr-x 7 tmux wheel 238 Jun 14 11:18 . drwxr-xr-x 3 root wheel 102 Jun 14 10:34 .. 

这里的问题是目录/ chroot / tmux上的所有权和权限。

SSHD手册指出:

ChrootDirectory

  Specifies the pathname of a directory to chroot(2) to after authentication. All components of the pathname must be root- owned directories that are not writable by any other user or group. After the chroot, sshd(8) changes the working directory to the user's home directory. 

我相信ChrootDirectory的具体path(在你的情况/ home / tmux)必须是root:root和最多755的权限,看起来你的目录是由'tmux'拥有的。

另外请注意,ChrootDirectory命令最适合SFTP,如果你想从这个目录运行交互的SSH命令行会话(和一个shell),你不需要特定的shell,你需要添加一些文件首先到chroot,如sshd_config手册页中所述:

ChrootDirectory必须包含必要的文件和直接支持用户的会话。 对于交互式会话,这需要至less一个通常为sh(1)的shell和诸如null(4),zero(4),stdin(4),stdout(4),stderr(4),arandom等基本/ dev节点(4)和tty(4)设备。 对于使用“sftp”的文件传输会话,如果使用正在运行的sftp服务器,则不需要额外的环境configuration,尽pipe使用日志logging的会话在chroot目录中需要/ dev / log(请参阅sftp-服务器(8))。