Sunday, January 25, 2009

Secure Copy on Linux System

Beside SSH, every linux is completed with scp or secure copy. Secure copy use to transfer between local and remote computer. Local computer can send a file/s or a directory/s to remote computer and vice versa. To understand how scp work, assume :

Local computer
Name : PC-1
IP : 192.168.1.86 (Private IP)
Username : msmunir
Passwrod : *******

Remote computer
Name : PC-2
IP : 202.46.2.222 (Public IP)
Username : msmunir
Password : ******

Case #1 : PC-1 send a file to PC-2

Code :
$ scp local_file user@remote_host:remote_folder

Case #2 : PC-1 send a folder to PC-2

Code :
$ scp -r local_folder user@remote_host:remote_folder

Case #3 : PC-1 receive a file from PC-2

Code :
$ scp user@remote_host:remote_folder local_folder

Case #4 : PC-1 receive a folder from PC-2

Code :
$ scp -r user@remote_host:remote_folder local_folder

Examples : (All commands are executed from PC-1)

Case #1 : PC-1 send a file to PC-2

[msmunir@msmunir1 ~]$ cd Desktop/
[msmunir@msmunir1 Desktop]$ cd mp3
[msmunir@msmunir1 mp3]$ pwd
/home/msmunir/Desktop/mp3
[msmunir@msmunir1 mp3]$ scp kool_and_the_gang-cherish.mp3
msmunir@202.46.2.222:/home/msmunir/
kool_and_the_gang-cherish.mp3 100% 3772KB 12.7KB/s
04:56
[msmunir@msmunir1 mp3]$

Case #2 : PC-1 send a folder to PC-2

[msmunir@msmunir1 ~]$ scp -r /home/msmunir/Desktop/mp3/ msmunir@202.46.2.222:/home/
msmunir/mp3/
Christopher_Cross-Arthur's_Theme_(Best_That_You_Can_Do).mp3 100%
3640KB 12.9KB/s 04:42
Aerosmith-I_Dont_Want_To_Miss.mp3 100% 4674KB 12.3KB/s
06:20
[msmunir@msmunir1 ~]$

Case #3 : PC-1 receive a file from PC-2

[msmunir@msmunir1 ~]$ scp msmunir@202.46.2.222:/home/msmunir/mp3/Human_Nature-
Eternal_Flame.mp3 /home/msmunir/Desktop/
Human_Nature-Eternal_Flame.mp3 100% 896KB 40.7KB/s
00:22
[msmunir@msmunir1 ~]$

Case #4 : PC-1 receive a folder from PC-2

[msmunir@msmunir1 ~]$ scp -r msmunir@202.46.2.222:/home/msmunir/mp3/
/home/msmunir/mp3/
Human_Nature-Eternal_Flame.mp3 100% 896KB 42.7KB/s
00:21
Christopher_Cross-Arthur's_Theme_(Best_That_You_Can_Do).mp3 100%
3080KB 42.8KB/s 01:12
[msmunir@msmunir1 ~]$
by. msmunir@batan.go.id

No comments:

Post a Comment