Using scp command I want to move files from local system to a remote system. I'm doing something like this:

$ scp file1 root@abc:root /root/tmp

With this command I'm able to upload file1 to abc:/root, but the problem is that it changes the names to tmp like in my case, I want to keep the name the same as the original and just copy it to the folder.

How can I do this?


Do this:

$ scp file1 root@abc:/root/tmp/

This would also work:

$ scp file1 root@abc:~/tmp/

If the directory /root/tmp isn't on the remote system abc, you can do this, and rsync will create the remote directory for you:

$ rsync -ave ssh file1 root@abc:/root/tmp

Lastly if you have to use ssh you can do this:

$ cat file1 | ssh root@abc "mkdir /root/tmp; cat >> /root/tmp/file1"
|improve this answer|||||

This means that the /root directory on abc does not contain a tmp sub-directory. One more thing: you're using an extra root in your command line. (It should be scp file1 root@abc:/root/tmp)

Here's what you should do:

  • First create the required sub-directory on abc:

    ssh root@abc 'mkdir /root/tmp'
  • Then copy the file into the newly-created sub-directory:

    scp file1 root@abc:/root/tmp
|improve this answer|||||

Just omit the final parameter, and the copied file will be /root/file1

scp file1 root@abc:root
|improve this answer|||||
  • but i want to place the FILE in root/tmp folder – asadz Jul 10 '13 at 22:10

When a destination is not followed by a slash, it is interpreted as a new name for the file unless that folder already exists. So either:

$ scp file1 root@abc:root /root/tmp/

Or create the /root/tmp/ directory, then:

$ scp file1 root@abc:root /root/tmp
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.