Hello, After a deeper investigation I think I can explain what happens. Special thanks to Jakub Jelen who did the server side investigation. Red Hat Enterprise Linux 8 series is based on OpenSSH 8.0, which is rather old. Soon after the OpenSSH 8.0 was published, the upstream introduced a server-side fix for sftp, which changes the use of POSIX realpath (on LInux) to the OpenBSD one with various quirks: https://github.com/openssh/openssh-portable/commit/569b650f93b561c09c655f83f128e1dfffe74101 If the OpenBSD realpath is in use on the server, the current master successfully copies directories using scp in SFTP mode. Otherwise problems occur. As RHEL 8 series will definitely be in wide use for several more years, I kindly ask the OpenSSH upstream to consider this patch, which is trying to workaround the server side on the client side: https://github.com/openssh/openssh-portable/pull/299 It's a slightly tidied up version of the POC patch I've sent to this ML before. Many thanks in advance! On Fri, Feb 4, 2022 at 11:15 AM Dmitry Belyavskiy <dbelyavs@xxxxxxxxxx> wrote: > > > On Fri, Feb 4, 2022 at 7:29 AM Dan Yefihmov <dan@xxxxxxxxxxxxxxxx> wrote: > >> On February 3, 2022 3:03:25 PM GMT+03:00, Dmitry Belyavskiy < >> dbelyavs@xxxxxxxxxx> wrote: >> >Dear Damien, >> > >> >Here is a proof-of-concept patch fixing this issue for me. If it could be >> >polished, it would be great. >> > >> Didn't you forget to free both error message string and ssh buffer in the >> error path after do_mkdir? >> > > I did, and there are definitely more problems related to this patch. I'll > try to elaborate a better version. > > -- > Dmitry Belyavskiy > -- Dmitry Belyavskiy _______________________________________________ openssh-unix-dev mailing list openssh-unix-dev@xxxxxxxxxxx https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev