When I try to scp a file with a slash in its path, the path is quoted for the local host, and the last path component is additionally quoted for the remote host, like
scp host:"a/b/'c'" ., it fails with
protocol error: filename does not match request
unless I use the
-T option. However, if any other path component is quoted, like
scp host:"a/'b'/c" ., it works. Also, if the path is not quoted for the local host, like
scp host:a/b/'c' ., it works.
The man page documents
Disable strict filename checking. By default when copying files from a remote host to a local directory scp checks that the received filenames match those requested on the command-line to prevent the remote end from sending unexpected or unwanted files. Because of differences in how various operating systems and shells interpret filename wildcards, these checks may cause wanted files to be rejected. This option disables these checks at the expense of fully trusting that the server will not send unexpected filenames.
I don't understand how this description explains the behavior I see. What is the rationale for scp's behavior? And is there any way to disable this "feature"?
I am running Ubuntu 16.04 and the remote host is running Ubuntu 12.04.