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

ssh how to allow a very limited user with no home to login with pubkey

· 52CE 我爱测

I have a very restricted user in my ssh server created with --no-create-home and --shell /bin/false . I know I can define authorized_keys file in sshd_configs for the user's public key. But how can I allow public key authenticati…

问题原文

原帖链接 · Mojtaba Rezaeian · CC BY-SA 4.0

I have a very restricted user in my ssh server created with --no-create-home and --shell /bin/false. I know I can define authorized_keys file in sshd_configs for the user's public key. But how can I allow public key authentication for this user without requiring to access any files on OS?

社区高分解答

原帖链接 · Ángel · CC BY-SA 4.0

diya has already explained that you could change to AuthorizedKeysCommand for retrieving the public key of a user.

However, it's probably easier for you to place the authorized_keys file somewhere else. For example you could set AuthorizedKeysFile /etc/ssh/authorizedkeys/%u and place the file that would have been at ~username/.ssh/authorized_keys at /etc/ssh/authorizedkeys/username instead.

And, if you want to change it only for this user (so other users still have their authorized_keys at ~/.ssh/), you could use

Match User username
AuthorizedKeysFile /some/path/username_authorized_keys

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

资料来源与适用范围

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

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

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