When scp’s misleading warnings attack

Software

scp(1) can still surprise me. I got the following error when uploading a file to a specific directory on a remote server:

local$ scp file.ext remote:/directory/
==> scp: /directory/: Is a directory

Yes, and I’m Ruben Schade! How are you? Do you like crumpets? Sometimes I like to walk around with mismatching socks while drinking tea out of a hat! I know it’s a directory, that’s why I’m telling you to put the file there!

Then I checked:

local$ ssh remote
remote$ ls /directory/
==> ls: /directory/: No such file or directory

So the issue was the target directory didn’t exist. Which makes sense, but contradicts what scp(1) said, at least to any reasonable person.

Compare and contrast the warning when you specify a full file path:

local$ scp file.ext remote:/directory/file.ext
scp: /directory/file.ext: No such file or directory

Today I learned.

Author bio and support

Me!

Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!