如何仅为 SFTP 登录启用 LDAP 身份验证

如何仅为 SFTP 登录启用 LDAP 身份验证

我目前使用名为 Centrify Express 的工具在我的 Ubuntu 10.04 服务器上使用 ActiveDirectory 进行身份验证。Centrify 有一个自定义 .so 文件,该文件在 /etc/pam.d/common-auth 中配置。

我想对 SFTP 用户(而不是 SSH 登录)进行常规 LDAP 身份验证(绕过 centrify)。我该如何配置 /etc/pam.d/sshd 以尝试对 SFTP 登录而不是 SSH 登录进行 LDAP 身份验证?我的想法是,我的 SFTP OU 将允许用户下载和上传文件,但他们无法获取 shell。

答案1

如果我理解你的问题正确的话,你希望提供仅有的 sftp服务(即没有通过 进行交互式登录ssh)。

sftp您可以通过将其添加到文件来强制连接使用该服务sshd_config

ForceCommand internal-sftp

这在手册页中有记录sshd_config

ForceCommand
  Forces the execution of the command specified by ForceCommand, ignoring any
  command supplied by the client and ~/.ssh/rc if present.  The command is
  invoked by using the user’s login shell with the -c option.  This applies to
  shell, command, or subsys- tem 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.

您可以修改/etc/pam.d/sshd配置 sshd 以使用普通pam_ldap模块而不是pamCentrify 提供的模块。

更改这些配置后,sftp连接将使用正常LDAP身份验证,并且交互式 shell 将不可用。

答案2

我认为你不能在 pam 中限制它,但是如果你让所有你想要的用户都限制一个组的成员,你可以让 ssh 通过 match group blah 限制这些用户可以做的事情。

相关内容