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
Logs:/var/log/secure

SCP

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/

Install

Yum install openssh-server

Checking

rpm –qa openssh-server

Service on

Chkconfig sshd on
Service sshd restart

Examples

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

$ scp your_username@remotehost.edu:foobar.txt /some/local/directory

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

$ scp foobar.txt your_username@remotehost.edu:/some/remote/directory

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


$ Scp  -r  foo your_username@remotehost.edu:/some/remote/directory/bar

Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu"


$ scp your_username@rh1.edu:/some/remote/directory/foobar.txt \
your_username@rh2.edu:/some/remote/directory/

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  your_username@remotehost.edu:~

Copy the file "foobar.txt" from the local host to a remote host using port 2264
$ scp -P 2264 foobar.txt  your_username@remotehost.edu:/some/remote/directory



No comments:

Post a Comment