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

What's the largest string OpenSSH can expand from a % token?

· 52CE 我爱测

Instead of a traditional authorized_keys file on my server, I'm using a custom key verifier which sshd calls via the AuthorizedKeysCommand option. In the sshd_config, I can specify that this command should be fed the user's publi…

问题原文

原帖链接 · data princess · CC BY-SA 4.0

Instead of a traditional authorized_keys file on my server, I'm using a custom key verifier which sshd calls via the AuthorizedKeysCommand option. In the sshd_config, I can specify that this command should be fed the user's public key as an argument, like so:

AuthorizedKeysCommand /path/to/verifier %k

The problem is that the key encodes a lot of additional data and so can be quite large. If it's bigger than around 4135 bytes, sshd logs a fatal error while expanding the %k token:

sshd[5914]: fatal: percent_expand: string too long

I've been combing through the source code of percent_expand and I don't see anywhere where this string too long error might be encountered. It appears that there is some kind of limit on the token size, but what is it? Where is it defined?

已采纳解答

原帖链接 · anx · CC BY-SA 4.0

You are using an older OpenSSH version that happens to limit the entire expansion buffer to 4096 octets. Update beyond 8.1, which you should, anyway.

The message you did not find in source code was removed in commit switch percent_expand() to use sshbuf instead of a limited fixed buffer - see OpenSSH-portable and OpenBSD upstream

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

资料来源与适用范围

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

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

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