For some reason I can no longer scp folders from my desktop Mac to our Linux server.

Here's the error:

(base) my_computer:~ username$ scp -r /source_directory/filename user@server:/home/user/destination
user@server's password: 
scp: realpath /home/user/filename: No such file
scp: upload "/home/user/filename": path canonicalization failed
scp: failed to upload directory /source_directory/filename to /home/user/destination

A few notes on the issue:

  • All of the files do exist. Specifically, /source_directory/filename exists, as does /home/user/destination, but /home/user/filename does not exist, nor should it exist before copying (it will exist after copying from source to destination).
  • I get the same error as above whether I'm trying to copy to the server from my computer's internal drive or from an external drive connected to my computer
  • I do not get this error on any other computers in our network
  • I used to be able to do this without issue
  • I can copy single files (like a .wav) without issue, but not a folder, even if it's empty and even if I'm not using the -r command
  • I have no problem copying from the server to my computer
  • I have no issue with ssh

What could be the cause? What solutions should I try?

Update 1:

When I try this: https://www.reddit.com/r/linuxquestions/comments/uj2y65/strange_scp_r_error/

I only get this:

usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2

Update 2:

My macOS is Ventura 13.1. None of my other computers uses this version, and I can successfully scp to the server from any of those other computers.

  • Does the directory user@server:/home/user/destination exist? Feb 23, 2023 at 23:50
  • @ajgringo619 /source_directory/filename exists, as does /home/user/destination, but /home/user/filename does not exist, not should it before copying. It will exist after copying from source to destination.
    – user90664
    Feb 24, 2023 at 0:50
  • Here's a possible solution: reddit.com/r/linuxquestions/comments/uj2y65/strange_scp_r_error Feb 24, 2023 at 0:54
  • Instead of answering to questions in comments, it's better to edit the question instead. This way it stays up-to-date reflecting your current situation, and everything relevant is readily available. Feb 24, 2023 at 0:55
  • 1
    @roaima Yes, the paths in the error are strange, but I have faithfully reported them in the post (with name changes), and all the original paths I used in my command are accurate (i.e., the files really exist, and really exist at the path I entered).
    – user90664
    Feb 24, 2023 at 19:56

1 Answer 1


I'm going to guess that you've mangled the paths in your question to avoid leaking what you consider to be sensitive information, but in doing so you've slightly altered the structure of the actual command used.

The path canonicalization failed error is a consequence of scp having been changed to use the SFTP protocol by default, and it now being stricter on paths than before. Specifically the new version requires that directories must not have a trailing slash, and spaces in path names must be escaped with a preceding backslash (\ ).

This will fail:

scp -r /source_directory/filename user@server:/home/user/destination/

This will succeed:

scp -r /source_directory/filename user@server:/home/user/destination

You can temporarily revert to using the original scp protocol with scp -O but this is not recommended, and won't even be an option for much longer. For further detail on the reasons for the change, read answers to the question Is scp unsafe? Should it be replaced with sftp?, particularly those that reference CVE-2019-6111.

  • None of those options works. And the paths are not mangled, I was careful to only change the names of things in my post.
    – user90664
    Feb 24, 2023 at 19:54
  • Apologies! The -o flag does work. At first I used a lowercase o instead of uppercase O. And now I'm assuming the change that caused this issue was updating the macOS.
    – user90664
    Feb 24, 2023 at 21:33
  • @user90664 good to hear you have a temporary fix with -O Feb 24, 2023 at 22:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .