I ssh-ed into my webhost's directory, and tar-ed the webapp to download. When I try to mv to ~/mydirectory/backups or /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 being inside the webhost's system?

6 Answers
6

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 user@example.com:/home/name/dir

(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 user@example.com:/home/name/dir/file /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 user@server.com:/some/remote/dir /home/youruser/remotecomp

4) Enjoy

5) "unlink" the dirs

fusermount -u /home/youruser/remotecomp

If the local computer runs windows
You can find versions of scp for windows. See, e.g, winscp

Is there a way to copy the file from the remote machine to the local machine via "terminal on the remote machine"? In your case, you used the terminal on the local machine. I'm talking about a situation where local machine is windows and remote is ubuntu and I'm logged to the remote machine via ssh.
– CKMMar 23 '17 at 8:13

Usually not. As far as I know, copying via "terminal in remote machine" means that you need an SSH server in the "local machine" (I purposefully skipped that during my answer, but "the fact that the remote computer accepts ssh connections" is meant to say "the fact that the remote computer is running an ssh server")
– josinalvoMay 30 '17 at 14:30

If you're transferring a large file, use rsync over ssh with rsync -P -e ssh /tmp/file user@example.com:/home/name/dir. This is because if a file transfer fails half way through, scp will just delete the file. On the other hand, if you use rsync with the -P option, it'll keep an incomplete file on the remote machine and when you restart the transfer, it'll make sure that what's already on the remote machine matches the file on your local machine and then continue where the transfer left off.
– BorisNov 2 '18 at 23:10

Great answer! Simple and closest to an answer to the actual question, i.e. How do you mv from within the ssh remote computer. The answer is you can't, you do it from the local computer. Or this! You do it graphically from your explorer so that at least to the user it indeed seems like you can move files directly from remote to local.
– KvotheJul 4 '18 at 14:49

The other answers recommend rsync or scp, both of which require you to know the location of the file you want to copy on the remote machine.

If you instead want to be able to poke around on the remote machine, like you can with ssh, you want to run sftp. Logging into the server is very similar to ssh, but once you get in, type help to get the list of commands - it lets you move yourself around on both the local and remote machines, and transfer files back and forth easily.