为 SFTP 启用密码登录,同时通过 SSH 密钥进行身份验证

Dr *_*NYU 7 ssh authentication sftp drupal7

如何为 SFTP 事务启用密码登录(由 Drupal 制作,如果这很重要),同时为所有其他基于 SSH 密钥的身份验证禁用密码登录?目前 CentOS 服务器的所有现有用户都使用密钥登录并且 /etc/ssh/sshd_config 有PasswordAuthentication no)?

Zor*_*che 13

据我所知,您想允许某些用户输入密码,而不允许其他用户输入密码?
你可以设置一个Match块。因此,您的配置可能如下所示。

...
PasswordAuthentication no
...
Match user drupalsftp
    PasswordAuthentication yes
Run Code Online (Sandbox Code Playgroud)

既然您提到这些基于密码的交易是从 drupal 发生的,也许您可​​以根据主机地址将其列入白名单? Match address 127.0.0.1/32

您甚至应该能够组合这些条件,并说只有来自特定地址的特定帐户才能进行密码验证。

PasswordAuthentication no
...
Match user drupalsftp address 10.1.2.3/32
    PasswordAuthentication yes
    # also since we want only sftp
    ForceCommand internal-sftp
Run Code Online (Sandbox Code Playgroud)

链接