We can use scp command to copy files and folders from one server to another server. Below is the syntax for scp command.
scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ...[[user@]host2:]file2
scp stands for secure cp (copy), which means you can copy files across ssh connection, it uses the port 22 by default.
scp -r /path/of/source-folder user@server:/path/to/destination-folder/
example: scp -r /tmp/somedirectory user1@122.1.1.197:/tmp/sampledirectory/
scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ...[[user@]host2:]file2
scp stands for secure cp (copy), which means you can copy files across ssh connection, it uses the port 22 by default.
- Copy File from Server 1 to Server 2, assuming you already logged in to server 1.
scp /path/of/file username@serverhost:/path/to/destination
example: scp /tmp/sample.txt user1@122.1.1.197:/tmp/sampledirectory/- Copy folders from Server 1 to Server 2, assuming you already logged in to server 1.
scp -r /path/of/source-folder user@server:/path/to/destination-folder/
example: scp -r /tmp/somedirectory user1@122.1.1.197:/tmp/sampledirectory/
Note: -r Recursively copy entire directories.
- Copy specific files under a folder from Server 1 to Server 2, assuming you already logged in to server 1.
scp /path/of/source-folder/*.txt user@server:/path/to/destination-folder/
example: scp /tmp/sample/*.txt user1@127.1.1.197:/home/sample/
No comments:
Post a Comment