SSH forcecommand,但不限制root

我使用ssh的“forcecommand”选项来传递一个shell脚本来帮助lockingssh用户。 我想知道如果他们是一种方法来做到这一点,而不强迫root也必须执行shell脚本。

谢谢!

sshd允许我们覆盖选定用户(用户,组,主机或地址)的默认设置。

我们可以使用Match块来实现这个function。 在Match块中,我们必须设置我们想要改变的条件和设置。

我不知道是否有可能在sshd_config取消选项(例如,通过使用不带参数的选项),但是如果不可能,您可以创build一组想要限制的用户,并将ForceCommand仅应用于该组。

configuration未设置的选项:

 Match User root ForceCommand #some way to unset option? 

configuration受限组:

 Match Group restrictedsshd ForceCommand /some/script.sh 

有关Match选项的更多信息,可以在man sshd_configfind。

man sshd (LOGIN PROCESS)
3. Checks /etc/nologin; if it exists, prints contents and quits (unless root).