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.
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.
1
|
scp test.txt sharad@192.168.1.19:/tmp
|
(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.
1
|
scp -r testdir sharad@192.168.1.19:/tmp
|
(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.
1
|
scp sharad@192.168.1.19:~/test.txt ~/Desktop
|
(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.
1
|
scp -r sharad@192.168.1.19:~/testdir ~/Desktop
|
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.
1
|
scp-P 2211 test.txt sharad@192.168.1.19:/tmp
|
(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.
1
|
scp -p 2211 -r testdir sharad@192.168.1.19:/tmp
|
(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.
1
|
scp -P 2211 sharad@192.168.1.19:~/test.txt ~/Desktop
|
(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.
1
|
scp -P 2211-r sharad@192.168.1.19:~/testdir ~/Desktop
|
No comments:
Post a Comment