How do I copy a folder from remote to local host using scp
?
I use ssh
to log in my server.
Then, I would like to copy the remote folder foo
to local /home/user/Desktop
.
How do I achieve this?
How do I copy a folder from remote to local host using scp
?
I use ssh
to log in my server.
Then, I would like to copy the remote folder foo
to local /home/user/Desktop
.
How do I achieve this?
Better to first compress catalog on remote server:
Secondly, download from remote:
At the end, extract the files:
To use full power of scp you need to go through next steps:
Then, for example if you have this ~/.ssh/config:
you'll save yourself from password entry and simplify scp syntax like this:
More over, you will be able to use remote path-completion:
Update:
For enabling remote bash-completion you need to have bash-shell on both
<source>
and<target>
hosts, and properly working bash-completion. For more information see related questions:How to enable autocompletion for remote paths when using scp?
SCP filename tab completion
I don't know why but I was had to use local folder before source server directive . to make it work
The question was how to copy a folder from remote to local with
scp
command.$ scp -r userRemote@remoteIp:/path/remoteDir /path/localDir
But here is the better way for do it with
sftp
- SSH File Transfer Protocol (also Secure File Transfer Protocol, or SFTP) is a network protocol that provides file access, file transfer, and file management over any reliable data stream.(wikipedia).$ sftp user_remote@remote_ip
sftp> cd /path/to/remoteDir
sftp> get -r remoteDir
Fetching /path/to/remoteDir to localDir 100% 398 0.4KB/s 00:00
For help about
sftp
command just typehelp
or?
.What I always use is:
. (dot) : it means
current folder
. so copy from server and paste here only.IP : can be an IP address like
125.55.41.311
or it can be host likens1.mysite.com
.