D Root
D Root

Reputation: 41

copy/move files on remote server linux

I log into server_a and run .sh file, which has the following script:

scp user@server_b:/my_folder/my_file.xml user@server_b:/my_new_folder/

to copy files from my_folder to my_new_folder at server_b. It doesn't throw an error, but no files are copied.

Notes:

The end goal is to move or copy/remove files.

Upvotes: 3

Views: 7124

Answers (2)

Jakuje
Jakuje

Reputation: 26016

There are two possibilities:

  1. Connect from server_a to server_b and do local copy:

    ssh user@server_b "cp /my_folder/my_file.xml /my_new_folder/"
    
  2. Do copy over the server_a. Your method would require the server_b to be able to authenticate to itself, which is probably not the case:

    scp -3 user@server_b:/my_folder/my_file.xml user@server_b:/my_new_folder/
    

Also note that your code copies only one file and not files as you write in the title.

Upvotes: 3

Zahid Gill
Zahid Gill

Reputation: 302

If you are logged on to the server, why are you authenticating again:

scp user@server_b:/my_folder/my_file.xml user@server_b:/my_new_folder/

You should be in the directory of file or simply use scp and use -v parameter to see the debug information.

Run as follows:

scp -v /my_folder/my_file.xml user@server_b:/my_new_folder/

It is not a directory nor it is recursive, so you do not need to -r parameter.

Upvotes: 0

Related Questions