大网数据广告活动
服务器运维问答

Security implications when only allowing logins via key and UsePAM setting is 'yes'?

· 52CE 我爱测

When setting up a new server, I generally want to allow logins only via key authentification and not from the root user. Therefore, I edit the sshd_config like this: I change 'PermitRootLogin' to 'no' and uncomment 'PasswordAuthe…

问题原文

原帖链接 · user40974 · CC BY-SA 3.0

When setting up a new server, I generally want to allow logins only via key authentification and not from the root user. Therefore, I edit the sshd_config like this:

I change 'PermitRootLogin' to 'no' and uncomment 'PasswordAuthentification' and set this to 'no' as well. While this works very well and I've checked and found no way to login only via password, I was wondering why some guides recommend to set 'UsePAM' to 'no' while other guides don't mention it at all (and thereby keep it as 'yes'). There seems to be no clear opinion on whether the UsePAM setting should be changed when switching to key only auth.

What are the security implications of leaving UsePAM as it is ('yes'), if there are any at all?

已采纳解答

原帖链接 · Matthew Ife · CC BY-SA 3.0

You keep UsePAM as yes because when PasswordAuthentication is set to no PAM does not call the 'auth' section of the PAM service:

UsePAM Enables the Pluggable Authentication Module interface. If set to “yes” this will enable PAM authentication using ChallengeResponseAuthentication and PasswordAuthentication in addition to PAM account and session module processing for all authentication types.

Because PAM challenge-response authentication usually serves an equivalent role to password authentication, you should disable either PasswordAuthentication or ChallengeResponseAuthentication.

If UsePAM is enabled, you will not be able to run sshd(8) as a non-root user. The default is “no”.

This way PAM runs through account and session types properly which is actually very important if you want to restrict access to servies based off of IP, time or other factors of the account. Additionally if you want to make sure users inherit certain environment variables on login or disallow access to the server when SELinux is disabled.

Its a common fallacy to think it runs through all the auth modules when PAM is enabled but password authentication is disabled.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。