Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I use my own laptop running Ubuntu to ssh to my school server (which is running another Linux distribution).

I do my assignments remotely like this, but I have an habit of putting all my files on Dropbox so that I can gain access of them anytime anywhere.

Question is:

for instance, I made a file named blah.cpp on the school server, thru ssh on my laptop, now I want to copy this file to my local machine into the Dropbox folder. What is the command to do that?

I've done the research and seems like scp and sftp are the solution but I find it hard to understand what exactly I should do with them.

share|improve this question

marked as duplicate by DavidPostill, karel, ᔕᖺᘎᕊ, alex, eldering Mar 9 '15 at 16:53

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.

scp to copy file from remote host sshfs to mount a remote folder onto a local one – Jokester May 7 '12 at 15:30
but like in this case, how do i copy the blah.cpp to my dropbox folder(/home/u/Dropbox) – Anson May 7 '12 at 15:33
Would it be possible to copy directly to your Dropbox account from the school server? – Scott Mar 7 '15 at 16:44

Run this command on your laptop, not ssh'ing or anything, just open up a terminal and run it. (replace some of the values perhaps to make it work)

scp youraccountnameonremotemachine@remotemachine:fileinyourhomedirectory .

This copies the file 'fileinyourhomedirectory' in your home directory (cpn. obvious) on the remote machine to the current path (='.') of your laptop.

For your example:

scp  anson@remoteserver:blah.cpp /home/u/Dropbox/

This is all easily understood, if you just read the contents of the manual of scp:

man scp
share|improve this answer
Thanks this worked and I ve got another 2 question. 1:can I scp folders? 2: now I have already sshed into the server, can I copy the file blah.cpp to my local laptop from within the server? And thanks but the manual page seemed very unhelpful and not straight forward to me. – Anson May 7 '12 at 15:44
1: use the -r parameter, it's the acronym for recursive 2: if you ssh to a machine, you're executing commands on that machine I don't think there is some kind of backlink to the machine you ssh'd from. So your copy-action would be a copy-to-remote action, the remote being your laptop. It's probably easier to just fire up Filezilla: – Gunther Struyf May 7 '12 at 15:56
Thank you! =] ... – Anson May 7 '12 at 16:00

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