Difference between revisions of "Linux and UNIX Secure Copy"
(2 intermediate revisions by one user not shown) | |||
Line 2: | Line 2: | ||
The command scp is used to copy files across ssh connection. You can use scp to copy files from or to a remote host. Using ssh for data transfer provides the same authentication and same level of security as ssh. | The command scp is used to copy files across ssh connection. You can use scp to copy files from or to a remote host. Using ssh for data transfer provides the same authentication and same level of security as ssh. | ||
+ | |||
+ | == usage examples == | ||
Examples: | Examples: | ||
− | Copy the file "foobar.txt" from a remote host to the local host | + | PULL - Copy the file "foobar.txt" from a remote host to the local host |
scp nicolep@remotehost.com:foobar.txt /usr/local/download | scp nicolep@remotehost.com:foobar.txt /usr/local/download | ||
− | Copy the file "foobar.txt" from the local host to a remote host | + | PUSH - Copy the file "foobar.txt" from the local host to a remote host |
scp foobar.txt nicolep@remotehost.com:/usr/local/download | scp foobar.txt nicolep@remotehost.com:/usr/local/download | ||
Line 28: | Line 30: | ||
scp nicolep@serverone.com:/usr/local/download/foobar.txt nicolep@servertwo.com:/home/nicolep | scp nicolep@serverone.com:/usr/local/download/foobar.txt nicolep@servertwo.com:/home/nicolep | ||
+ | == spaces in file path == | ||
+ | |||
+ | Backslashing alone doesn't do the job, you have to escape and black slash. | ||
+ | |||
+ | example: | ||
+ | |||
+ | scp nicolep@192.168.10.8:/mnt/public/download/OS\\\ ISO\\\ Images\\\ ALL/debian-8.7.1-i386-netinst.iso ./ | ||
+ | |||
+ | == installation == | ||
+ | |||
+ | Red Hat Enterprise Linux, CentOS, Trustix | ||
+ | |||
+ | yum install openssh-clients | ||
+ | |||
+ | Debian or Ubuntu | ||
+ | |||
+ | apt-get install openssh-client | ||
[[Category:Computer_Technology]] | [[Category:Computer_Technology]] | ||
[[Category:Linux]] | [[Category:Linux]] |
Latest revision as of 10:00, 21 February 2018
This article is about the scp command.
The command scp is used to copy files across ssh connection. You can use scp to copy files from or to a remote host. Using ssh for data transfer provides the same authentication and same level of security as ssh.
usage examples
Examples:
PULL - Copy the file "foobar.txt" from a remote host to the local host
scp nicolep@remotehost.com:foobar.txt /usr/local/download
PUSH - Copy the file "foobar.txt" from the local host to a remote host
scp foobar.txt nicolep@remotehost.com:/usr/local/download
More examples:
Recursively copy entire directories. This will get all the web directories and sub-directories and copy to the local machine
scp -r bob@10.0.0.1:/home/httpd/html/* /home/httpd/html
The -r is the flag for recursive
Now to copy all files in the current working directory to a remote server web directory
scp * nicolep@10.0.0.9:/var/www/html
Copy a file from one remote host to another, neither file residing nor resulting on the current machine.
scp nicolep@serverone.com:/usr/local/download/foobar.txt nicolep@servertwo.com:/home/nicolep
spaces in file path
Backslashing alone doesn't do the job, you have to escape and black slash.
example:
scp nicolep@192.168.10.8:/mnt/public/download/OS\\\ ISO\\\ Images\\\ ALL/debian-8.7.1-i386-netinst.iso ./
installation
Red Hat Enterprise Linux, CentOS, Trustix
yum install openssh-clients
Debian or Ubuntu
apt-get install openssh-client