This comes up with surprising frequency:
I am on a server or other machine via ssh. I want to scp or rsync some files back to my client machine. The problem is that I am behind a firewall and I don't have a port mapped to port 22 on my machine.
It would be great if I could somehow alias the machine that I am connected from in an scp or rsync command something like:

scp fileToBeTransferred LOCALMACHINE:~/temp/

My current process is to issue the command from my local machine (not in an ssh session). It would just be so much faster to be able to issue the scp command from the server because I'm already in the correct directory, I can use file completion, and my credentials are already verified.

My client machine is almost always a Mac running Mountain Lion if that makes a difference.

I tried this and it did not work. The connection times out on the scp command. Is there a good way to troubleshoot the port? This reverse tunnel works from behind a firewall? My machine has a private IP, the firewall does NAT. BTW I used 12345 as the port # in both commands (easier on my old eyes)
–
ScottJan 9 '13 at 18:08

fixed the typo. it should work with 12345 too. is your local ssh service running and accepting connections? (not locally firewalled via iptables, selinux and what not)?
–
GryphiusJan 9 '13 at 18:11

ignore the selinux comment, I forgot you're on a mac. I'm not familiar with that os, so maybe someone else can help debug. maybe there is some security feature preventing connections to your local ssh port?
–
GryphiusJan 9 '13 at 18:24

I can ssh to the local machine from other machines on the private network, so the ssh service is running
–
ScottJan 9 '13 at 18:39