How to send multiple folders using SSH (SCP)

0

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

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

But the command is giving error:

  

No such file or directory

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

  • Why does it say the file was not found?
  • How do I send multiple folders (public_html, app, vendor, etc ...) at once?
asked by anonymous 20.10.2017 / 14:07

1 answer

3

By the SCP definition, you need to specify the source path (OK) and 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 ("all at once") as long as they are all within the ./ public_html directory (in your example). To send files individually, you need a shell script that lists the files and runs the one-by-one (something by merging find with xargs ).
  • -p to port.

You have even had to specify the destination path. How would the command: (note the : / var / www / ):

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

Another important detail is permission. The user-ssh user must be writable in the / var / www / directory.

Note: The port can not be at the end of the command, otherwise it is confused with the destination directory.     

20.10.2017 / 14:29