SCP copying error : Not a directory
Asked Answered
H

3

9

I want to copy a file from my local system to a remote host. I want to specify the file name while copying.

This is my command for copying.

scp config/1 root@remote:/home/user/config/2

I want to rename the file while copying or with the same name like this.

scp config/1 root@remote:/home/user/config/1

But I dont want to use like the below command.

scp config/1 root@remote:/home/user/config/

When I specify the filename i get the error: Not a directory

Historicism answered 28/7, 2016 at 6:25 Comment(3)
what is your file name... 1?Monarda
yes . 1 is my file nameHistoricism
if destination file exists, maybe scp assumes it's a directory, tries to copy in 1/1 then fails.Tomekatomes
D
5

This is a known bug in openssh, unfortunately not fixed, even though there is a patch for that.

In short, it means that the file does not exists, but the scp is confused by the trailing slash.

Dwight answered 28/7, 2016 at 9:16 Comment(4)
Now It is fixed :)Historicism
I'm still getting this as well 😞Longinus
@Longinus still not fixed.Dwight
@Jakuje, a peer helped figured it out. Try to go to the local folder and scp *.js [email protected]:/folder/Longinus
M
1

You need to run the scp command from the local machine, not on the remote. You don't need the ssh at all:

user@local $ scp -P 2222 file.ext username@domain:~/ 
Monarda answered 28/7, 2016 at 6:36 Comment(1)
The username@domain part uses SSH.Longinus
U
0

I got error "Not a directory" when tried scp with "-p" instead of "-P" for remote port number. Check your syntaxis.

Underclothes answered 2/5, 2023 at 17:40 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.