Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What cause the error "Couldn't canonicalise: No such file or directory" in SFTP?

Tags:

sftp

I am trying to use SFTP to upload the entire directory to remote host but I got a error.(I know SCP does work, but I really want to figure out the problem of SFTP.)

I used the command as below: (echo "put -r LargeFile/"; echo quit)|sftp -vb - username@remotehost:TEST/

But I got the error "Couldn't canonicalise: No such file or directory""Unable to canonicalise path "/home/s1238262/TEST/LargeFile"

I thought it was caused by access rights. So, I opened a SFTP connection to the remote host in interactive mode and tried to create a new directory "LargeFile" in TEST/. And I succeeded. Then, I used the same command as above to uploading the entire directory "LargeFile". I also succeeded. The subdirectories in LargeFile were create or copied automatically.

So, I am confused. It seems only the LargeFile/ directory cannot be created in non-interactive mode. What's wrong with it or my command?

like image 980
dmoney Avatar asked Jul 04 '13 19:07

dmoney


4 Answers

With SFTP you can only copy if the directory exists. So

> mkdir LargeFile
> put -r path_to_large_file/LargeFile

Same as the advice in the link from @Vidhuran but this should save you some reading.

like image 104
Joe Susnick Avatar answered Oct 05 '22 15:10

Joe Susnick


This error could possibly occur because of the -r option. Refer https://unix.stackexchange.com/questions/7004/uploading-directories-with-sftp

like image 43
Vidhuran Avatar answered Oct 05 '22 17:10

Vidhuran


The easiest way for me was to zip my folder on local LargeFile.zip and simply put LargeFile.zip

zip -r LargeFile.zip LargeFile
sftp www.mywebserver.com (or ip of the webserver)
put LargeFile.zip (it will be on your remote server local directory)
unzip Largefile.zip
like image 22
Papouche Guinslyzinho Avatar answered Oct 05 '22 17:10

Papouche Guinslyzinho


A better way is through using scp.

scp -r LargeFile/"; echo quit)|sftp -vb - username@remotehost:TEST/
like image 36
Salah Avatar answered Oct 05 '22 17:10

Salah