Remote Linux Server to Remote Linux Server Dir Copy. How

How to copy files and folders from one remote server to another remote server using scp command?

I presume that your problem is with specifying a wildcard. You can avoid this difficulty using a recursive copy from a directory with a trailing slash, vis:

scp -r root@64.211.219.95:/var/www/ root@42.11.37.153:/var/www/project_dir

The scp command can be run from any server you like, not restricted to the source or destination machine.

Copying sub-folders from remote machine to remote machine directory

if you use scp you can use -r option, like this

scp  -r /usr/share/hub-bucket/GameImages/  user@remote-host:/usr/share/hub-bucket/GameImages/

you can also use rsync command

rsync -avz /usr/share/hub-bucket/GameImages/ user@remote-host:/usr/share/hub-bucket/GameImages/

How do I copy a folder from remote to local using scp?

scp -r user@your.server.example.com:/path/to/foo /home/user/Desktop/

By not including the trailing '/' at the end of foo, you will copy the directory itself (including contents), rather than only the contents of the directory.

From man scp (See online manual)

-r Recursively copy entire directories

copy/move files on remote server linux

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.

How can I copy file from local server to remote with creating directories which absent via SSH?

I can make the same directories on the remote servers and copy file to it via SSH by using SCP like this:

cd /root/dir1/dir2/
ssh -n root@192.168.0.19 "mkdir -p '$PWD'"
scp -p filename root@192.168.0.19:$PWD/

Copy .sh file from my local computer to the remote server

Imagine hello.txt is the file you want to move. Directory you are standing on contains this file.

Run scp hello.txt root@YOUR_SERVER:/root.

This will copy hello.txt to your root's home directory. Run cd ~ on your server and you will see your file.

In this example I used root account, but you can also use another account too



Related Topics



Leave a reply



Submit