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 happily use both ssh and scp.

Quite often I am in an ssh session and I'd like to retrieve a file from my machine and put it in the directory I'm currently in without having to open a new terminal window and work out the scp command. So effectively i'd like to be able to do this:

remotemachine#scp homeconnection:thisfile.txt .

without opening an scp server on my machine. Is it possible to use the open ssh connection to do the copy or am I stuck going in and out of ssh?


share|improve this question
possible duplicate of does ssh have a facility to exchange files when already connected? – Kenster Jan 9 '15 at 12:00

To recieve file

ssh cat > localfile "<" remotefile
ssh "cat remotefile" | cat > localfile

To send a file

ssh cat < localfile ">" remotefile
cat localfile | ssh "cat > remotefile"

share|improve this answer
Don't those have to be run from outside of the ssh session I'm in? like scp? – Joe Jan 7 '15 at 19:53
Yes. Technically no as you could ssh into your own machine and run the commands but that would be pointless. After re-reading your question the answer is no. You could press ctrl+z to backgroud the session then run scp. then type fg to bring your ssh session back up. You could also setup remote port forwarding if your machine is behind NAT. Then run something like scp eg. scp -P 8080(forwarded port) user@homemachine:example example – Tim Williams Jan 8 '15 at 1:01

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.