Upload directory by sftp

2

I try to upload localDir to remote server i follow this guide SFTP Guide

but when upload the localDir and go inside i see blankDir I did the following

sftp> lls
404.html  crm nginx-logo.png  test.php

sftp> ls
 crm

sftp> put -r crm /usr/share/nginx/html
      Uploading crm/ to /usr/share/nginx/html/crm
      Entering crm/

I created crm dir according to the following note in SFTP Guide

Note

There is currently a bug in the versions of OpenSSH shipped with current >Ubuntu releases (at least 14.04 to 15.10) that prevents the above command >from operating correctly. Upon issuing the command above to transfer content >to a server using the buggy version of OpenSSH, the following error will be >given: Couldn't canonicalise: No such file or directory.

To work around this issue, create the destination directory on the remote >end first by typing mkdir localDirectory. Afterwards, the above command >should complete without error.

but upload file working well.

Any Suggestions ?

Just User

Posted 2016-01-12T18:56:31.160

Reputation: 133

yeah i know the help guide for SFTP by help or ? i will update my que – Just User – 2016-01-12T19:04:48.347

I have all permissions , i uploaded file to this dir to check worked well – Just User – 2016-01-12T19:19:17.087

The same result sftp> put -r crm Uploading crm/ to /usr/share/nginx/html/crm Entering crm/

After mkdir crm2 and ls i see crm2 – Just User – 2016-01-12T19:29:31.933

The SFTP Guide with my Que note us to create this dir look at put section – Just User – 2016-01-12T19:37:38.373

1Yes, I see where it shows put -r localDirectory with the localDirectory in your case will be /crm but the location where you are uploading it to on the server (/usr/share/nginx/html/) the /crm is already there. If you're in /usr/share/nginx/html/ then run rmdir crm and then do the put -r crm to see if it shows what you're expecting. I think the /crm is already where you are trying to upload it to, or I'm totally lost which is absolutely possible... put I do FTP stuff all the time... Perhaps the error isn't clear to me. – Pimp Juice IT – 2016-01-12T19:42:35.007

sftp> pwd Remote working directory: /usr/share/nginx/html sftp> lpwd Local working directory: /var/www/nginx/html sftp> put -r crm Uploading crm/ to /usr/share/nginx/html/crm Couldn't canonicalize: No such file or directory Unable to canonicalize path "/usr/share/nginx/html/crm" – Just User – 2016-01-12T19:46:46.257

1I noticed where it said the workaround to that issue you added to your answer is to make the directory first and then upload it. So you'd run mkdir crm and then run put -r crm. – Pimp Juice IT – 2016-01-12T19:47:13.330

I swear i did that i created crm before uplodaing – Just User – 2016-01-12T19:48:30.010

this issue drive me to crazy , anyway you deserve a big thank for your help . – Just User – 2016-01-12T19:50:32.557

Answers

2

Your Error

enter image description here

To resolve your error per your comment, just run mkdir crm and then run put -r crm.

The same flags that work with "get" apply to "put". So to copy an entire local directory, you can issue:

put -r localDirectory

Note

There is currently a bug in the versions of OpenSSH shipped with current Ubuntu releases (at least 14.04 to 15.10) that prevents the above command from operating correctly. Upon issuing the command above to transfer content to a server using the buggy version of OpenSSH, the following error will be given: Couldn't canonicalise: No such file or directory.

To work around this issue, create the destination directory on the remote end first by typing mkdir localDirectory. Afterwards, the above command should complete without error.

Pimp Juice IT

Posted 2016-01-12T18:56:31.160

Reputation: 29 425