Когда я добавляю пользователей в разделе PAM sshd_config:
UsePAM yes
Match User employee_1
PasswordAuthentication yes
Я не могу перезапустить сервис SSH и получить сообщение ниже (Почему? помогите):
root@ip-xxxxxxx:/etc/ssh# systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-04-23 18:19:00 UTC; 19s ago
Process: 895 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=0/SUCCESS)
Process: 2183 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=255)
Main PID: 895 (code=exited, status=0/SUCCESS)
Apr 23 18:19:00 ip-publicip systemd[1]: ssh.service: Control process exited, code=exited status=255
Apr 23 18:19:00 ip-publicip systemd[1]: ssh.service: Failed with result 'exit-code'.
Apr 23 18:19:00 ip-publicip systemd[1]: Failed to start OpenBSD Secure Shell server.
Apr 23 18:19:00 ip-publicip systemd[1]: ssh.service: Service hold-off time over, scheduling restart.
Apr 23 18:19:00 ip-publicip systemd[1]: ssh.service: Scheduled restart job, restart counter is at 5.
Apr 23 18:19:00 ip-publicip systemd[1]: Stopped OpenBSD Secure Shell server.
Apr 23 18:19:00 ip-publicip systemd[1]: ssh.service: Start request repeated too quickly.
Apr 23 18:19:00 ip-publicip systemd[1]: ssh.service: Failed with result 'exit-code'.
Apr 23 18:19:00 ip-publicip systemd[1]: Failed to start OpenBSD Secure Shell server.
В файле sshd_config
действительно нет «разделов».
В файле по умолчанию UsePAM
является последней строкой файла, и поэтому вы обычно видите блоки Match
, следующие сразу за ним. Правила для блоков Match
описаны в man sshd_config
:
blockquote>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 satisfied, only the first instance of the keyword is applied.
Как мы обнаружили, запустив сервер в режиме отладки с
sshd -d
, у вас есть по крайней мере один дополнительная строка послеUsePAM
в вашем файлеsshd_config
, и, поместив блок соответствия перед этой строкой,sshd
пытается применить его внутри блока - что недопустимо (см.Match
раздел справочной страницы снова, чтобы увидеть подмножество разрешенных ключевых слов):/etc/ssh/sshd_config line 94: Directive 'PrintMotd' is not allowed within a Match block
Решение должно быть таким же простым, как перемещение вашего блока
Match
в истинный конец файла.