Red Hat Bugzilla – Bug 1263237
sftp doesn't handle '#' within filenames for transfer
Last modified: 2016-02-21 19:58:51 EST
the upstream bug was closed with resolution "WORKSFORME", which means that there was nothing fixed in openssh-7.1 related to this bug. The official proposed solution is to use quotes around the strings with # characters.
The behavior looks a bit different from default bash behavior and from the last comment and my testing emerges that the proposed solution doesn't work much on command-line with scp syntax, regardless the quotes:
$ sftp localhost:"/tmp/a#a"
File "/tmp/a" not found.
The only workaround I found was to use batch file (and public key authentication):
$ sftp -b <(echo 'get "/tmp/c#c"') localhost
sftp> get "/tmp/c#c"
$ ls c#c
Changing this behavior in this late release would be problematic and could result in regression. If customer is not satisfied with batch-mode-solution, I will try to reopen upstream bug and discuss our use case.