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.