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

OpenSSH internal-sftp not accepting allowed/denied_requests

· 52CE 我爱测

Trying to set up a highly restricted SFTP server with OpenSSH_7.4p1 for remote scripts to upload data. The goal is a black hole where the scripts can do a "put" with user level keys and no other server commands are possible. Ever…

问题原文

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

Trying to set up a highly restricted SFTP server with OpenSSH_7.4p1 for remote scripts to upload data. The goal is a black hole where the scripts can do a "put" with user level keys and no other server commands are possible. Everything worked fine until the final step where I tried to the limit the sftp command set using -P and -p options in this sshd_config Match clause:

Match user globalstat
    ChrootDirectory /inbound
    ForceCommand internal-sftp -d data -p put -P df,pwd,rm,mkdir,rmdir,get,rename,symlink

Tried a variety of combinations, but -P for denied_requests never blocks any of the specified remote commands. Applying allowed_requests with -p put or put,cd breaks the transfer and returns "Couldn't canonicalise: Permission denied Need cwd". Without -P or -p, there is no problem with the writes, and based on other postings for this error, I'm pretty sure my directory permissions are correct. I've been using this man page for a reference:
https://www.man7.org/linux/man-pages/man8/sftp-server.8.html

It implies that Subsystem rather than ForceCommand is the place for these options, but they don't work in the main body of sshd_config and restarting sshd throws an error if Subsystem is used in a Match clause instead of ForceCommand.

I really hope it's possible to get this working and any suggestions would be greatly appreciated.

已采纳解答

原帖链接 · Martin Prikryl · CC BY-SA 4.0

The arguments to -p/-P are names of low-level SFTP protocol requests. Not the high-level OpenSSH sftp client commands.

These are the names: open, close, read, write, lstat, fstat, setstat, fsetstat, opendir, readdir, remove, mkdir, rmdir, realpath, stat, rename, readlink, symlink, posix-rename, statvfs, fstatvfs, hardlink, fsync, lsetstat.

You can get the up to date list by running sftp-server -Q requests, as sftp-server man page says.

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

资料来源与适用范围

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

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

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