Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know I can use sftp user@host ....

But what I want is to download a file from the existing session.

that is.

ssh user@host ... do some work ...

The main problem I have is that said file is under root on the server so doing a sftp command is not that simple.

share|improve this question
SSH doesn't provide a download facility that you can use within an interactive session, excepting screen captures, but you can use scp as described below. the "main problem" you describe is very vague; please clarify what you're trying to do and what errors you get. exact commands would help. –  quack quixote Apr 16 '10 at 1:28

3 Answers 3

I don't know why it has to be the same session, but if you use ControlMaster and ControlPath in your ~/.ssh/config you don't have to authorize your scp connection since it multiplexes in the same connection. This also speeds up your connection you do to the same host.

Have a look at http://www.linux.com/archive/feed/54498 on how to set it up.

share|improve this answer

Have you tried scp? For example:

scp user@host:/path/to/remote-file .
share|improve this answer

The way you describe it it sounds like your issue is that you cannot login as root via ssh (probably you used some sort of su or sudo to work as root).

  • If root can in principle log in via ssh, but you do not know the password, you can set up root's account to allow public-key authentication with your key.
  • If that is not possible copy that file to a folder accessible to the account you log in with (like your $HOME folder), possibly adjust permissions and copy as user with sftp or scp.
share|improve this answer
Also, if you're logged in and can somehow see that file remotely, can't you just copy it to /tmp temporarily, then scp (or sftp) it down? –  khedron Apr 15 '10 at 21:49
@khedron depending on the file /tmp might be a little bit too visible, but that's hard to tell from the question –  Benjamin Bannier Apr 15 '10 at 21:49

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.