If you are logged in to a system via SSH, is there a way to copy a file back to my local system without firing up another terminal or screen session and doing scp or something similar or without doing SSH from the remote system back to the local system?
- You can mount the remote file system on your local machine with sshfs:
Another (IMO) way would be:
Or if you prefer something GUI-like, try Midnight Commander. They call the feature Shell-Link. Most distros have em in their package systems as mc.
- If the file is small, you can type it out and copy-paste from the terminal output.
- If the file contains non-printable characters, use an encoding such as base64.
More conveniently, if you have X forwarding active, copy the file on the remote machine and paste it locally.
You can pipe data in and out of xclip or xsel. If you want to preserve the file name and metadata, copy-paste an archive.
- You can either use scp or rsync.
In your local system:
But, since you mentioned backup, I assume that it would be incremental and you’ll need to do it every now and then. So, rsync is a better choice for incremental backup.
On your local shell:
see rsync(1)and scp(1) man pages for options.
- You could use scp secure copy.
From you local shell:
This example will copy via ssh from /path/of-the/tar.archive of your webhost to /home/mydirectory/backups/
-C: Enables compression
- The best efficient solution is to use xclip-copyfile and xclip-pastefile.
- On the server, you use xclip-copyfile to copy one or more files.
- These files are then available on your local server. There, you can use xclip-pastefile.
- This bypasses the need to use scp or have a local ssh server. you use this with cygwin for instance.
- The only problem is that this requires installing xclip if you don’t already have it and this works with binary files too.