Friday, October 24, 2014

how to configure scp in linux?

Secure copy or SCP is a means of securely transferring  computer files between a local host and a remote host or between two remote hosts. It is based on the  Secure Shell (SSH) protocol.

Package name: openssh-server
Service : sshd
Port no:22
Configure file:/etc/ssh/sshd_config


The scp command allows you to copy files over ssh connections. This is pretty useful if you want to transport files between computers, for example to backup something. The scp command uses the ssh command and they are very much alike. However, there are some important differences.

The scp command can be used in three* ways: to copy from a (remote) server to your computer, to copy from your computer to a (remote) server, and to copy from a (remote) server to another (remote) server. In the third case, the data is transferred directly between the servers; your own computer will only tell the servers what to do. These options are very useful for a lot of things that require files to be transferred, so let’s have a look at the syntax of this command

[root@linux~]$ scp examplefile yourusername@yourserver:/home/yourusername/

You can also copy a file (or multiple files) from the (remote) server to your own computer. Let’s have a look at an example of that:

[root@linux~]$ scp yourusername@yourserver:/home/yourusername/examplefile .

You probably already guessed that the following command copies a file from a (remote) server to another (remote) server:

[root@linux~]$ scp yourusername@yourserver:/home/yourusername/examplefile yourusername2@yourserver2:/home/yourusername2/


Yum install openssh-server


rpm –qa openssh-server

Service on

Chkconfig sshd on
Service sshd restart


Copy the file "foobar.txt" from a remote host to the local host

$ scp /some/local/directory

Copy the file "foobar.txt" from the local host to a remote host

$ scp foobar.txt

Copy the directory "foo" from the local host to a remote host's directory "bar"

$ Scp  -r  foo

Copy the file "foobar.txt" from remote host "" to remote host ""

$ scp \

Copying the files "foo.txt" and "bar.txt" from the local host to your home directory on the remote host

$ scp foo.txt bar.txt

Copy the file "foobar.txt" from the local host to a remote host using port 2264
$ scp -P 2264 foobar.txt

No comments:

Post a Comment