Wednesday, September 3, 2014

[Quick Tips] : SCP file and directory in linux and Unix like operating system

SCP file and directory in linux and Unix like operating system

SCP stands for secure copy.It is based upon SSH (Secure Shell) protocol.SCP is used for securely transferring the files between local and remote system.
Note: If SSH service is not running or deny by firewall or IPTABLES of system then SCP will also not work.
Syntax:
scp SOURCE-FILE-LOCATION TARGET-LOCATION
(1) SCP file from local to remote system
Run the below given command from your system
scp filename remote-username@remote-ip-address:/path/to/transfer/file
eg.
(2) SCP Directory from local to remote system
Run the below given command from your system
scp -r directory-name remote-username@remote-ip-address:/path/to/transfer/directory
eg.
(3) SCP file from remote to local system
Run the below given command from your system
scp remote-username@remote-ip-address:/path/of/target-FILE /path/in/your/localSystem
eg.
(4) SCP directory from remote to local system
Run the below given command from your system
scp remote-username@remote-ip-address:/path/of/target-DIRECTORY /path/in/your/localSystem
eg.

If SSH port no. is changed from port no. 22 to other one

SSH port no. = 2211
(Note: SSH port no. might be different in your case hence give your ssh port no. instead of 2211)
Syntax:
scp -P port.no SOURCE-FILE-LOCATION TARGET-LOCATION
(1A) SCP file from local to remote system
Run the below given command from your system
scp -P port.no. filename remote-username@remote-ip-address:/path/to/transfer/file
eg.
(2A) SCP Directory from local to remote system
Run the below given command from your system
scp -P port.no -r directory-name remote-username@remote-ip-address:/path/to/transfer/directory
eg.
(3A) SCP file from remote to local system
Run the below given command from your system
scp -P port.no remote-username@remote-ip-address:/path/of/target-FILE /path/in/your/localSystem
eg.
(4A) SCP directory from remote to local system
Run the below given command from your system
scp -P port.no remote-username@remote-ip-address:/path/of/target-DIRECTORY /path/in/your/localSystem
eg.

No comments: