user4603311
user4603311

Reputation:

scp not working saying its a directory error

I am trying to copy a file to remote server in a certain folder.

Its an adrive backup plan. But it comes with scp. I can copy the file if I don't select directory. Even if I put a directory that doesn't exist it says its a directory.

root@host1 [/usr/src]# scp ftpdelete.sh user@[email protected]:/mysql-only/
scp: /mysql-only/: Is a directory

Upvotes: 35

Views: 52929

Answers (8)

C Wing
C Wing

Reputation: 21

Don't put "/" after the directory's name.

Upvotes: 2

Firas BC
Firas BC

Reputation: 13

Try to download the file directly to your local root directory and then copy it from there : root@host1 [/usr/src]# scp user@host:/root/Desktop/file.txt /root/home/

Upvotes: 0

Oleg Svechkarenko
Oleg Svechkarenko

Reputation: 2516

I saw a similar error, when tried scp to path that relative to home directory. The error fixed after removing unnecessary leading / in path:

# scp ftpdelete.sh user@[email protected]:mysql-only/

rather then

# scp ftpdelete.sh user@[email protected]:/mysql-only/
                                            ^

Upvotes: 3

Lerner Zhang
Lerner Zhang

Reputation: 7130

You are copying the sh file to a new directory on the server, and the directory is expected to be there but in fact not(then the machine thinks you want to change the file to be a directory). Most probably the directory you set is wrong.

Upvotes: 7

Amazingly enough in my case it was that the directory didn't exists!! :| Is the error message a bug?... or it's me. Tempted for the latter.

Upvotes: 61

sudhir kumar mishra
sudhir kumar mishra

Reputation: 116

scp -r source_location user@servername:/target_location

Upvotes: 2

HashSu
HashSu

Reputation: 1517

-r' Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal.
But it doesn't create a directory but you can do below

ssh remote mkdir /diretcory

root@host1 [/usr/src]# scp -r ftpdelete.sh user@[email protected]:/complete_path/mysql-only/

or

rsync can do the creating of directory if not exist its basic command syntax is similar to scp:²

$ rsync -r -e ssh ftpdelete.sh me@my-system:/complete_path/mysql-only/

Upvotes: 3

Jakuje
Jakuje

Reputation: 25956

SCP doesn't automatically create you new directory if you want to scp file (it creates directory only if you do recursive copy). There is wrong error message. The error should be No such file or directory or similar.

It is known problem and there is upstream bugzilla about this [1].

[1] https://bugzilla.mindrot.org/show_bug.cgi?id=1768

Upvotes: 21

Related Questions