Enter your email address:

Delivered by FeedBurner

scp - Linux command line tool to copy files over ssh


StumbleUpon Toolbar

scp stands for secure cp (copy), which means that you can copy files across an ssh connection that will be encrypted, and therefore secured.

You can this way copy files from or to a remote server, you can even copy files from one remote server to another remote server, without passing through your PC.

Usage

scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]

Description of options

from-host
Is the name or IP of the host where the source file is, this can be omitted if the from-host is the host where you are actually issuing the command
user
Is the user which have the right to access the file and directory that is supposed to be copied in the cas of the from-host and the user who has the rights to write in the to-host
source-file
Is the file or files that are going to be copied to the destination host, it can be a directory but in that case you need to specify the -r option to copy the contents of the directory
destination-file
Is the name that the copied file is going to take in the to-host, if none is given all copied files are going to maintain its names

Options

-p
Preserves the modification and access times, as well as the permissions of the source-file in the destination-file
-q
Do not display the progress bar
-r
Recursive, so it copies the contents of the source-file (directory in this case) recursively
-v
Displays debugging messages

Examples

scp *.txt user@remote.server.com:/home/user/

This will copy all files with .txt extension to the directory /home/user in the remote.server.com host

scp -r miguel@10.1.2.2:/home/miguel/ miguel@10.1.2.3:/home/miguel/

This is going to recursively copy all files from miguel's Home directory on 10.1.2.2 host to his Home directory in 10.1.2.3 host.

Note

To use this command you need to have open-ssh installed in the hosts.

Trackback URL for this post:

http://www.go2linux.org/trackback/154
StumbleUpon Toolbar

 If you like this article, subscribe to our full rss

If this article was somehow useful for you, you can leave something in the tip's jar

Please post your question in our forum and use comments only to leave your comments about the article, thanks.

you can also use the -C

you can also use the -C parameter to compress the data before sending or even better use rsync over ssh.

Yes thank you for the -C

Yes thank you for the -C option I did not know that, about rsync over ssh, here is what I wrote about it.

rsync over ssh

Guillermo Garron

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

This site is proudly hosted at Bluefur Hosting