SSH path canonicalization failed

Yet another “change stuff just to change stuff” explanation and fix.

Problem: you see “No such file” or “path canonicalization failed” after an scp command line that used to work correctly.

tim@timub2404:~/eclipse-work$ scp -r  socialsecurity.git tim@reposerver:/home/tim/
tim@reposerver's password: 
scp: realpath /home/tim/socialsecurity.git: No such file
scp: upload "/home/tim/socialsecurity.git": path canonicalization failed
scp: failed to upload directory socialsecurity.git to /home/tim/

Fix: add a “-O” argument to your “scp” command line:

The -O tells scp to use the Original algorithm.

tim@timub2404:~/eclipse-work$ scp -r -O socialsecurity.git tim@reposerver:/home/tim/
tim@reposerver's password: 
HEAD                                          100%   21    11.5KB/s   00:00    
0b582a00b112f748f21bb23ffa752914571733        100%  824   319.8KB/s   00:00    
fc089c9ada51bd2c992218e71b647639bd1120        100%  845   612.1KB/s   00:00    
14e202e45d6fe94144ae5e3545733e82bdb4e5        100%   97    70.1KB/s   00:00    
f12d4f4f39d216b56f6682949bcca46446b7ae        100%  563   447.5KB/s   00:00    
715629da406ea4cfd88368c4d0e94fc0a13495        100%   67    60.4KB/s   00:00    
feea6d6b116baaca5a2642d4d9fa1f47d574a7        100% 3984     2.1MB/s   00:00    
9886bd634a78fb1368398cc1a610437a7d87d8        100% 2359     1.4MB/s   00:00    
9aac13e2f1984b1c9715c6b803cab56536ba69        100%   49    14.8KB/s   00:00    
751e5d7d72f17ed8deabe0b752a1c65d3c17cf        100%  355   232.1KB/s   00:00    
7b14b5afff06bb839a1e811f5afe5d6957d5ad        100%   69    41.5KB/s   00:00    
97f7119c02b00d6daaf28265c1f7bfc1b448da        100%  474   249.1KB/s   00:00    
61dba6a32004e3cbdf2262e92359fbe63e1f15        100%   46    27.9KB/s   00:00    
f13b90f13c70e5c88f3f09ed2e432d606c042f        100%   75    55.1KB/s   00:00    
a59af59654690b7081ce89d70c29d7661daed4        100%  548   467.3KB/s   00:00    
61ce4d98c3cc4e50a3c7a10c50836ce68c24d8        100%  281   186.3KB/s   00:00    
4d581ea07a78135e0e7f78cbc06358ce4e4fcb        100%  113    62.5KB/s   00:00    
5ed5312ebf4cc671a5fb204134cd15bf63d3d6        100%   45    34.2KB/s   00:00    
44014230357fb523f457f64ac9ba60d79c1f4d        100%   56    40.7KB/s   00:00    
b03d72877bfac39d72d22a5d7c5ee62ef34949        100%  195   158.3KB/s   00:00    
60825fdf26f069eb0c559f1ca8f6e19ad383e0        100%   68    60.8KB/s   00:00    
6cdbf7f808b7a8200d3c89614ce4b1171a4b56        100%   68    60.9KB/s   00:00    
6d1ce9f07a6f430a7f3036560efdef82bd5a5c        100%  720   660.7KB/s   00:00    
94c41587a4d76830583962d845deb8b78ea7c2        100%   46    41.1KB/s   00:00    
523c0e5490700d1a647ecf95309b5f7f9a8199        100%  169   106.7KB/s   00:00    
f4ee8dfcb028929455f0c379fd7b6f8b514cce        100%  773   247.6KB/s   00:00    
21a21834d5195c278ba17baec3115b2aaab06e        100% 1297   716.1KB/s   00:00    
cbf4e081a680b2acec85c2028f8746631fe049        100%  295   220.4KB/s   00:00    
dbb6330fedcb23afe1a9de87be15b3a08c9a2f        100%  195   173.0KB/s   00:00    
ffd0ec1f1659e26337b8ad49a2945301c4b926        100%  134   123.0KB/s   00:00    
2181caf06724916192c3dee29534652b913b2e        100%  494   397.6KB/s   00:00    
47a08398ef3c7e159970196d37b2538753bb3e        100%  275   268.4KB/s   00:00    
5eecf2e5e81b21ac13e4f89a392c11677cf206        100%   49    34.5KB/s   00:00    
33490cb1a052d1ccea9212ae5a23f56225bb6b        100%   57    59.8KB/s   00:00    
ed26f6d936b22b430ab653ca52f8b13dd64c1b        100%   57    42.4KB/s   00:00    
cd73148622dfc0b0bb48892fda4a7ceeb417aa        100%  163   141.4KB/s   00:00    
69e12e5e04363229cc95bd4ff88f7735a47fc6        100%  187    60.8KB/s   00:00    
4c7fbd4c28d8e1e4c9e0902e1e80c20bf1b711        100% 1178   489.5KB/s   00:00    
a25b35d8ff40f5e52eb26789bb0a4c17e65a9d        100%  103    29.3KB/s   00:00    
b6356614c9bda105daf0c536f39ec30194a601        100%  133   117.6KB/s   00:00    
793cb26015909c07a01a30b8b16e608ed0b070        100%   95    89.2KB/s   00:00    
837e152999a54b9558c8f34810c7ecaeb1cbfc        100%   56    40.0KB/s   00:00    
1f64602e6c6d892d70d71f4fc7a1bd943e23f3        100%  192   143.1KB/s   00:00    
6985c0094c8e3db5f1c6e2c4d66b82f325284f        100%   90    56.4KB/s   00:00    
6b183dbb1eca60906749887b025a9fc31307b5        100%   69    52.2KB/s   00:00    
edcd0c541a19204aa2e6dc73feb3e681180188        100%   46    37.1KB/s   00:00    
3521197d7c4586c843d1d3e9090525f1898cde        100%   38KB  10.6MB/s   00:00    
605b481fd7b9e232fcd8e121f171a425c7b291        100% 2664     1.7MB/s   00:00    
cf155fa6b337fadfa47a70f6e21652913d0f6b        100%  276   210.0KB/s   00:00    
0f386ed7bab65f858fb4600352af97ac9783da        100% 1323   968.0KB/s   00:00    
264592d922e071c3c88cdcf42fdd63d6b8c1d4        100%  479   368.0KB/s   00:00    
git-daemon-export-ok                          100%    0     0.0KB/s   00:00    
commit-msg.sample                             100%  896   734.8KB/s   00:00    
pre-merge-commit.sample                       100%  416   184.7KB/s   00:00    
update.sample                                 100% 3650     2.2MB/s   00:00    
push-to-checkout.sample                       100% 2783     2.0MB/s   00:00    
pre-commit.sample                             100% 1643     1.3MB/s   00:00    
post-update.sample                            100%  189   139.3KB/s   00:00    
pre-receive.sample                            100%  544   375.9KB/s   00:00    
pre-push.sample                               100% 1374   970.2KB/s   00:00    
fsmonitor-watchman.sample                     100% 4726     2.5MB/s   00:00    
pre-applypatch.sample                         100%  424   296.5KB/s   00:00    
applypatch-msg.sample                         100%  478   360.3KB/s   00:00    
pre-rebase.sample                             100% 4898     1.8MB/s   00:00    
sendemail-validate.sample                     100% 2308     1.0MB/s   00:00    
prepare-commit-msg.sample                     100% 1492   446.9KB/s   00:00    
description                                   100%   73    51.5KB/s   00:00    
packed-refs                                   100%  103    78.7KB/s   00:00    
exclude                                       100%  240   171.9KB/s   00:00    
config                                        100%  136    98.3KB/s   00:00    

Do you care why you need “-O”? I know I don’t. Ubuntu 24.04 upgraded its version of scp, so now you need it. The current man page says “The legacy SCP protocol (selected by the -O flag) requires execution of the remote user’s shell to perform glob(3) pattern matching. This requires careful quoting of any characters that have special meaning to the remote shell, such as quote characters.”

Which, for the above example, is just incorrect. The command line has no “~” or anything else that requires glob() pattern matching.

BTW – another valid work-around is to put your directory into a single .tgz file, and scp that without the -r command line argument.

This entry was posted in Software Project, Ubuntu. Bookmark the permalink.