scp -r does not seem to work on zsh, no idea why
Asked Answered
H

2

6

I can scp files to a remote host, but if I try to scp -r a directory it does not work

scp -r mydir [email protected]:/where/the/dir/has/to/go/
scp: realpath /whatever/mydir: No such file
scp: upload "/whatever/mydir": path canonicalization failed
scp: failed to upload directory cf2t to /where/the/dir/has/to/go/

I thought it was some issue with globbing, so I quoted different parts of the damn command to no avail.

Hydroxyl answered 8/11, 2022 at 10:54 Comment(6)
Does realpath mydir give any errors or do anything funny?Sheepwalk
Nope. There are no symlinks or anything else.Hydroxyl
Is your scp really what you think, or maybe an alias or shell function? Do a type -a scp. Aside from this, your command does not use anything tricky specific to zsh. In particular you don't do any globbing, and as long as the path does not have spaces or other characters specific to the shell, you don't need to quote anything. With this type of error, you better post the exact path name which you have used.Easel
type -a scp scp is an alias for noglob scp_wrap scp is /usr/bin/scpHydroxyl
I've noticed this issue as well after the latest MacOS upgrade (not sure that's the cause).Cindiecindra
Same issue on bash, Manjaro Linux. But I can scp -r remote to localElderly
S
1
  1. on remote.host: mkdir -p /where/the/dir/has/to/go/
  2. on local host: scp -r mydir [email protected]:/where/the/dir/has/to/go/
Siddur answered 10/2, 2023 at 7:29 Comment(0)
D
1

When trying to scp a directory to a raspberry pi via scp with an ssh key, I would put in scp -i ~/.ssh/ssh_filename -r directoryname [email protected]:/home/pi. It would return scp: realpath /home/pi/directoryname: No such file.

What this means is it looks for a directory of the same name at the destination, because it won't make a directory for you when you scp. At one point it would, but not anymore. Just make that directory at the destination. After that, you can scp and transfer the directory contents.

Alternatively, you could just zip the file, nix the -r, and unzip it once it arrives. unzip directoryname.zip

Dirndl answered 16/3, 2023 at 14:45 Comment(1)
But but but I did make a directory with scp just this morning (Linux to Linux, no idea what version of scp)Hydroxyl

© 2022 - 2024 — McMap. All rights reserved.