path to local file using ssh command to upload directory to remote server?

17,552

The folder you are trying to copy into does not exist on your server and scp will not create it for you. You can copy a local folder recursively into an existing folder on your target machine as

scp -r localfolder name@host:destination

and you will now have destination/localfolder at the remote system.

If you want to copy the files into destination, but not the localfolder itself you can use

scp -r localfolder/* name@host:destination

and your files (and subdirectories) from local folder will now be in your destination on the remote system.

But I don't know of any way for scp to create the destination folder should it not exist.

Share:
17,552
Ledgemonkey
Author by

Ledgemonkey

Updated on July 30, 2022

Comments

  • Ledgemonkey
    Ledgemonkey almost 2 years

    I'm trying to upload a folder from my local machine to a remote server using putty command.

    I'm trying to copy a folder and subfolder using this syntax

    scp -r [file/folder to be copied] some_user@my_ip:[destination_folder]
    

    I can login ok and run the command but get an error to the local path ?

    I have tried different paths to the local folder ie. c:/folder/folder - /folder/folder etc but i get an error saying no such file or directory exists - so I'm asking what is the correct path to include if the folder you want to copy is on your local machine - c:/documents/upload/folder

  • Roger Lindsjö
    Roger Lindsjö over 12 years
    The scp I have used (on GNU/Linux, Solaris, OSX have all supported the -r argument). pscp on window is also documented to copy recursively with -r.
  • Ledgemonkey
    Ledgemonkey over 12 years
    What is the correct path on my local machine if the folder is in c:/documents/folder ?