【问题标题】:Tried to chroot user but broke SSH access尝试 chroot 用户但破坏了 SSH 访问
【发布时间】:2014-11-01 02:41:55
【问题描述】:

我想将用户 a chroot 到其主目录。

所以我编辑了sshd_config 并在Subsystem sftp internal-sftp 之后添加了这些行:

Match Group agroup
    ChrootDirectory %h
    ForceCommand internal-sftp
    AllowTcpForwarding no

当然,agroup 是一个只有a 作为成员的组。我保存了文件,运行 service ssh restart 并繁荣,即使使用 rootPermitRootLogin 是打开的)我也无法再 SSH。为什么?当我尝试访问时,我得到“No route to host”。 从已经打开的 ssh 连接中,我设法再次编辑 sshd_config 并注释新行。

我做错了什么?

【问题讨论】:

  • 你能重现这个并通过尝试连接获得ssh -vvv 输出吗? No route to host 对我来说听起来像是一个网络(不是 ssh)问题。

标签: shell ubuntu ssh console


【解决方案1】:

我怀疑您的 Match 块不在 sshd_config 的末尾,并且您的 match 块之后出现的行之一对于您的 sshd 正常启动是必要的。

来自 man sshd_config:

Match   Introduces a conditional block.  If all of the criteria on the Match line are
        satisfied, the keywords on the following lines override those set in the global
        section of the config file, until either another Match line or the end of the
        file.  If a keyword appears in multiple Match blocks that are satisified, only
        the first instance of the keyword is applied.

也就是说,在您的匹配块之后和文件末尾之前不是另一个匹配块的任何内容都将被忽略。

我认为,如果您将 Match 块移动到 sshd_config 的最后,它应该对您有用。

【讨论】:

  • 是的..这很简单。 :)
猜你喜欢
  • 2012-04-30
  • 1970-01-01
  • 1970-01-01
  • 2021-11-11
  • 2020-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-02
相关资源
最近更新 更多