shell - such - ssh copy folder from local to remote
How to copy a folder from remote to local using scp? (8)
And if you have one hell of a files to download from the remote location and if you don't much care about security, try changing the scp default encryption (Triple-DES) to something like 'blowfish'.
This will reduce file copying time drastically.
scp -c blowfish -r [email protected]:/path/to/foo /home/user/Desktop/
How to copy a folder from remote to local host using
ssh to log in my server.
Then, I would like to copy the remote folder
foo to local
How to achieve this?
Better to first compress catalog on remote server:
tar czfP backup.tar.gz /path/to/catalog
Secondly, download from remote:
scp [email protected]:/path/to/backup.tar.gz .
At the end, extract the files:
tar -xzvf backup.tar.gz
I dont know why but I was had to use local folder before source server directive . to make it work
scp -r . [email protected]:/usr/share/nginx/www/example.org
In case you run into "Too many authentication failures", specify the exact SSH key you have added to your severs ssh server:
scp -r -i /path/to/local/key [email protected]:/path/to/folder /your/local/target/dir
To copy all from Local Location to Remote Location (Upload)
scp -r /path/from/destination [email protected]:/path/to/destination
To copy all from Remote Location to Local Location (Download)
scp -r [email protected]:/path/from/destination /path/to/destination
Custom Port where
xxxx is custom port number
scp -r -P xxxx [email protected]:/path/from/destination /path/to/destination
Copy on current directory from Remote to Local
scp -r [email protected]:/path/from/file .
-rRecursively copy all directories and files
- Always use full location from
/, Get full location by
scpwill replace all existing files
hostnamewill be hostname or IP address
- if custom port is needed (besides port 22) use
- . (dot) - it means current working directory, So download/copy from server and paste here only.
Note: Sometimes the custom port will not work due to the port not being allowed in the firewall, so make sure that custom port is allowed in the firewall for incoming and outgoing connection
To use full power of scp you need to go through next steps:
Then, for example if you'll have this ~/.ssh/config:
Host test User testuser HostName test-site.com Port 22022 Host prod User produser HostName production-site.com Port 22022
you'll save yourself from password entry and simplify scp syntax like this:
scp -r prod:/path/foo /home/user/Desktop # copy to local scp -r prod:/path/foo test:/tmp # copy from remote prod to remote test
More over, you will be able to use remote path-completion:
scp test:/var/log/ # press tab twice Display all 151 possibilities? (y or n)
For enabling remote bash-completion you need to have bash-shell on both
<target> hosts, and properly working bash-completion. For more information see related questions:
What I always use is:
scp -r [email protected]:/path/to/server/source/folder/ .
. (dot) : it means
current folder. so copy from server and paste here only.
IP : can be an IP address like
188.8.131.521 or it can be host like