限制对Debian服务器的SSH shell访问

对于整个Debian来说还是新事物,所以对我很感兴趣。

唯一我想要一个用户通过SSHlogin。 在这一点上应该没有文件或目录(如/ etc,/ var)。

用户唯一能做的就是“su”login到root,然后pipe理系统。

这样做是为了增加安全性。 每一点帮助正确?

显然chroot不是那么安全(在这里看到一个答案,似乎无法find链接tho)。

您可以使用ForceCommand来避免给用户任何shell访问权限。

  ForceCommand Forces the execution of the command specified by ForceCommand, ignoring any command supplied by the client and ~/.ssh/rc if pre- sent. The command is invoked by using the user's login shell with the -c option. This applies to shell, command, or subsystem execution. It is most useful inside a Match block. The command originally supplied by the client is available in the SSH_ORIGINAL_COMMAND environment variable. Specifying a command of ``internal-sftp'' will force the use of an in-process sftp server that requires no support files when used with ChrootDirectory. 

如果你真的想限制访问,那么我build议使用sudo,并且只启用这个用户所需的命令来pipe理你select的应用程序。

用户唯一能做的就是“su”login到root,然后pipe理系统。

这样做是为了增加安全性。 每一点帮助正确?

错误。

如果你想root能够login,你应该只允许rootlogin。

作为用户login,然后做su来成为root是一个非常复杂和不太安全的方式:

  • 一般情况下,任何事情都可能失败,所以你要求用户做更多的步骤,更多的机会是一步出错(“错误”我是说你没有做正确的事情,有人攻击你的服务器)
  • 您将强制inputroot密码,而使用ssh密钥login时可能会更安全,而无需input任何密码。 或者使用ssh键和必须input他们的密码短语,以增加安全性

如果你真的不知道你想要什么,你最好保持简单,并使用由知道自己在做什么的人编写的标准程序。 很明显,你不是一个安全专家,因此认为你可能提出的任何事情都是由专家完成的,或者被丢弃为毫无价值的,或者从来没有发生过的,因为它没有任何意义。

你可能想知道如何使用ssh-keygen以及如何configurationsshd_config。