Secure Copy in Linux
Copy from Server to Local Computer
Utilizing this command scp username@ip-server:/path/ke/file.txt /lokasi/di/local.
scp user@192.168.1.12:/home/user/file.txt ~/Download
Upload from Local to Server
Ini untuk upload file dari local ke server. scp ~/lokasi/file/di/local user@ip-server:/path/ke/lokasi.
scp ~/Documents/file.txt user@192.168.1.12:/home/user/Downloads
There are several option you are able to use, such as:
-P using your desire port. like -P 22.
example:
scp -P 2223 user@192.168.1.12:/home/user/Project/file.txt ~/Downloads
Command tersebut akan mengcopy file.txt ke dalam directory Downloads lewat port 2223.
example:
-r recursive, if you need to copy all of file inside a directory.
scp -r ~/Downloads/directory-main user@192.168.1.12:/home/user/Projects/
Perintah tersebut, akan mengupload semua file yang ada di directory directory-main ke dalam directory server Projects.
-i using private key.
example:
scp -i ~/.ssh/id_rsh/ssh-key.pem ~/Documents/file.txt user@192.168.1.12:/home/user/Projects
Ini dilakukan ketika si server tidak menerima login via password.
-C using compres data (it is faster if your files are too big).
example:
scp -C bigfile.zip user@192.168.1.20:/home/user/Documents
Gunakan ini untuk kompresi file yang berukuran besar agar mempercepat data transfering.
Addition : You can combine all of command like
scp -r -P 2345 -i ~/.ssh/id_rsa ~/Projects user@192.168.6.123:/home/user/Downloads
Command ini akan mengupload semua file di directory Projects ke directory server Downloads dengan private key dan melewati port 2345.
