How to send multiple folders using SSH (SCP)

Asked

Viewed 450 times

0

I have a "deploy.sh" file that has the following command:

scp -r ./public_html [email protected] -p 9922

But the command keeps giving error:

No such file or directory

But the folder public_html is in the same file directory deploy.sh.

  • Why does he say the file was not found?
  • How do I send multiple folders (public_html, app, vendor, etc...) at once?

1 answer

3


By setting the SCP, you need to specify the source path (OK) and the destination path (NOT OK). See man page scp

scp ... [user@]host1:]file1 ... [user@]host2:]file2

The other parameters you specified are correct:

  • -r for recursive. This you use to send multiple files within the specified path ("at once"), as long as they are all inside the directory ./public_html (in your example). To send files individually, you need a shell script that lists the files and sends them one by one (something merging the find with the xargs).
  • -p door-to-door.

The destination path was missing. How would the command look: (note the :/var/www/):

scp -p 9922 -r ./public_html [email protected]:/var/www/

Another detail very important is the permission. The user usuario-ssh must have written permission in the directory /var/www/.

Note: The port cannot be at the end of the command, but is confused with the destination directory.

  • I set the path according to the server :/home/meusite.com/public/ even so it did not give. It continues the same error "No such file or directory", I removed the port and it failed to connect.

  • 1

    I was able to solve the error by passing the port parameter to the beginning of the command: scp -p 9922 [user@]host1:]file1 ... [user@]host2:]file2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.