Using scp (secure copy) to Copy Files Between Computers

Copy a file from your local computer to a remote host using secure copy, scp (which uses ssh for data transfer and provides the same security as using ssh).

scp [filename] [username]@remotehost:[location]

scp file_to_copy.txt

copy a directory to your home computer from the remote computer.

scp -r directory_to_copy

copy a directory from a remote server to the current directory on your computer.

scp -r folder [username]@remotehost:[location] .

scp -r .

If you don’t have automated keys setup you will be asked for the password for that user.

An example for copying a MySQL database. Including the : without a location puts the file in the home folder.

mysqldump database_name -uroot > database_dump.sql
scp database_dump.sql

Then ssh into the remote server and open the mysql prompt

mysql -uroot -p
 mysql> create database database_name;
 mysql> exit

Then run the mysqldump file

mysql database_name -uuser -p < database_dump.sql

Remember to create the database user on the new machine (this has to match what is in the wp-config.php file).

2 thoughts on “Using scp (secure copy) to Copy Files Between Computers

  1. Pingback: Rsync to copy Files Between Servers and Computers | Coding and Server Syntax Examples

  2. Pingback: Chrome Remote Desktop | Coding and Server Syntax Examples

Leave a Reply

Your email address will not be published. Required fields are marked *

This Blog will give regular Commentators DoFollow Status. Implemented from IT Blögg