Filter files received on scp server

Malcolm opensshdev at
Fri Aug 4 17:28:35 AEST 2017

> I am hoping to filter on that file name so I can reject certain files
> (ideally, configurable file patterns).  Suppose I wish for all files named
> "kitten.txt" to be rejected, I would simply compare the incoming file name
> to that and, if a match, end the transfer and session.

Look at the okname() function in scp.c.

You'd have to think about how to implement this so you can:

1) Not expose yourself to unnecessarily risky code and functionality.
2) Provide for a (scalable) way to configure the list of "blacklisted"
filenames so that it doesn't require undue -HUP (or worse, recompilation) of
the SSH services.
3) Resist the tempation to use risky libraries to expand the flexibility of
your "blacklisting" specifications, i.e., PCRE & friends.


More information about the openssh-unix-dev mailing list