I am logged to remote server via ssh (linux) or via putty(windows). I want to copy file back to my origin machine from remote bash prompt (because of convenience). I know I can launch FileZilla or WinSCP at my machine and copy files, but I would like to know how to do that from remote bash prompt.

I know I can copy files via pscp using another ssh link:

pscp server.file localuser@local:/local_path

But this is impossible to use if client does not run a openssh server.

I see that my server has some variables like SSH_CLIENT, SSH_CONNECTION etc. Is it possible to use this information to craft a command like this?

copy_from_server server.file local.file

Where server.file is file located on the server (local to bash prompt where copy_from_server runs) and local.file is destination on client machine where file should be copied.

I would like a solution that works for windows and linux but I am also open to solutions that work on linux only or on windows only.

EDIT: Similar questions:

marked as duplicate by music2myear, Scott, Nifle, Dave M, bwDraco Oct 27 '14 at 2:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • No, that can't be done. Also, this is a duplicate of the link you give, and the answer there is also "no". – Jan Sep 30 '14 at 8:03
  • It cannot be done without additional software I guess. Now, I am tinkering with method of tunneling rsync port to remote server and to use rsync to copy files. I hope it will be possible with little configuration to accomplish that. – Jiri Sep 30 '14 at 11:18
  • While this could be done using a *nix client using the command line SSH program, it can't be done with Putty. tar -cf - /some/file | ssh host.name tar -xf - -C /destination would be how to do that. Note that for a variety of reasons, it's usually better to just use software more suited to the task, but it will work in a pinch. – 0xDAFACADE Oct 1 '14 at 18:53

While in your ssh session (not PuTTY), press Enter~C to enter a command line on your local machine.

At the shell you can run a command by prefixing it with !:

$ ssh> !scp <user@server:file> <local path>

Once the file has been copied the command prompt will exit and you'll be returned to your ssh session without the need to re-enter your credentials.

You'll need PermitLocalCommand=yes in /etc/ssh_config (client) for this to work.


You can use rsync for this. Look for examples of rsync command on the internet. Here is an example:

rsync -av -e ssh /var/www/your-site.com/ VPS_IP:/var/www/your-site.com/

I found this by reading about a Wordpress migration at: http://bit.ly/1pGp5cw

Not the answer you're looking for? Browse other questions tagged or ask your own question.