Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Probably bad searching/not knowing the terminology, but: I've managed to ssh into my webhost's directory for me, and tar the webapp I want to back up and download. But when I try to mv to ~/mydirectory/backups or mv to /home/mydirectory/backups, it defines the "home" as my root on the webhost that I'm ssh'ed into.

How do I mv in ssh to a local drive while still "inside" the webhost's system?

share|improve this question
What OS are you connecting from? – Zoredache Jun 29 '12 at 0:15
up vote 69 down vote accepted

First things first: ssh is a way to remotely login to another computer. The shell (command line) you get after you ssh is (pretty much) the same as if you had opened a xterm in the remote machine. If offers no such way to move files.

However, the fact that the remote computer accepts ssh connections gives you some options to exchange files:

Use scp To copy from your local computer to the remote, type, in the local computer:

scp /tmp/file

(where /tmp/file can be replaced with any local file and /home/name/dir with any remote directory)

To copy from the remote computer to the local one, type, in the local computer:

scp /tmp

Use sshfs This is a little more advanced but much, much nicer (when the internet connection of both computers is good. If not, stick to scp)

You can "link" a directory from the remote computer to an (empty) directory of the local computer. Say you "link" the /some/remote/dir from the remote computer to /home/youruser/remotecomp in your computer. If there is a file /some/remote/dir/file in the remote computer, you can see it on /home/youruser/remotecomp/file. You can copy and mv as usual, and you can even alter remote files and dirs.

Note however, that when the connection ends, /home/youruser/remotecomp becomes an empty dir again, and you only keep in the local computer the files you copied to other directories

To achieve this:

1) install sshfs:

sudo apt-get install sshfs

2) create a empty dir

mkdir /home/youruser/remotecomp

3) "link" the two directories (the right term is mount)

sshfs /home/youruser/remotecomp

4) Enjoy

5) "unlink" the dirs

fusermount -u /home/youruser/remotecomp

share|improve this answer

You can either use scp or rsync. In your local system:

scp remoteuser@remotehost:/remote/dir/file /local/dir/

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:

rsync -avz -e ssh remoteuser@remotehost:/remote/dir /local/dir/

see rsync(1)and scp(1) man pages for options.

share|improve this answer

You could use scp secure copy.

From you local shell:

scp -C username@webhost:/path/of-the/tar.archive /home/mydirectory/backups/

This example will copy via ssh from /path/of-the/tar.archive of your webhost to /home/mydirectory/backups/

Extra options:

-C: Enables compression

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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