Using scp to copy from a server and to a server

Copy files from the server to your pc

You need ssh access, view this post to do that:

Add ssh keys and ssh access to a linux server

The command to scp from server to your computer

1
sudo scp -i ~/.ssh/id_rsa user@server:A B

eg

1
sudo scp -i ~/.ssh/id_rsa user@server:/the/filepath/on/server/**/* /filepath/of/computer

/**/* refers to all files and subfolders

Copy files from your pc to the server

The normal way to scp, where you copy files from your computer to the server

1
scp -r A user@server:B

eg:

1
scp -r /path/on/your/computer/ user@server:/path/to/server/destination

-r means recursive (so all files and sub folders)

Wildcards

You can use wildcards to match with a file extension

1
eg *.php

That will copy all php files only.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.