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:
Connect from
server_a
toserver_b
and do local copy:ssh user@server_b "cp /my_folder/my_file.xml /my_new_folder/"
Do copy over the
server_a
. Your method would require theserver_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
Size() VS Ls -La VS Du -H Which One Is Correct Size
How to Print a Single Ascii Char
Use Find Command But Exclude Files in Two Directories
Linux Tool to Send Raw Data to a Tcp Server
How to Set a Global Nofile Limit to Avoid "Many Open Files" Error
Linux Memory Reporting Discrepancy
Warning Building a Kernel Module That Uses Exported Symbols
How to Gain Root Permission Without Leaving Vim
Why Can Back-Quotes and $() for Command Substitution Result in Different Output
What Does a Hexadecimal Number, with a Register in Parenthesis Mean in Assembly
What Should I Choose: Gtk+ or Qt
Svn Error: Can't Convert String from Native Encoding to 'Utf-8'
Gcc Compilation "Cannot Compute Suffix of Object Files: Cannot Compile"
Granting Access Permission to a File to a Specific User
Save in a Variable The Number of Seconds a Process Took to Run