Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 10-15-2006, 05:57 PM   #1
Registered: Nov 2005
Location: New Jersey, USA
Distribution: SuSE
Posts: 492

Rep: Reputation: 31
Program to transfer file 'backwards' over SSH


Computer A is behind a NAT router. Computer A can access the world, but nothing external can find its way to Computer A because of the router.

Computer B is world-accessible for SSH. I can SSH and SFTP from A to B but not from B to A.

The problem:

I want to be able to transfer files from B to A.

Is there any program out there which will let me SSH from A into B, and then from B, at the command line, send a file back to A over the already established SSH connection?

I know this assumes a persistent connection, but that isn't much of an issue.

I just want to be able to sit at computer A, open an SSH (or SFTP) session to B, then go over to B and be able to send files back to A.

Is this possible?

Old 10-15-2006, 06:33 PM   #2
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96

Two ways to do this:

1) Just use sftp, and 'get' whatever you need

ssh user@remotehost "cat /path/to/remote/filename" > /path/to/local/filename

Last edited by ilikejam; 10-15-2006 at 06:35 PM.
Old 10-15-2006, 06:39 PM   #3
LQ Guru
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 62
Check into the -R option for ssh. It allows reverse mapping. Might be what you are after.

Old 10-15-2006, 07:42 PM   #4
Registered: Sep 2005
Location: US
Distribution: Gentoo AMD64 Testing
Posts: 129

Rep: Reputation: 16
If you use scp you can put the remote file on whatever side you want:

scp .
would get the file from to the local system

will get the file from the local system, and put it on
Old 10-16-2006, 11:03 PM   #5
Registered: Nov 2005
Location: New Jersey, USA
Distribution: SuSE
Posts: 492

Original Poster
Rep: Reputation: 31
Originally Posted by Brian1
Check into the -R option for ssh. It allows reverse mapping. Might be what you are after.

I'll look into the docs. Do you know how I would implement this for rcp, or rlogin?

The two previous posts seem to have misunderstood my point.

I want to upload a file from Computer A to Computer B, where B can't connect to A, and I NO LONGER HAVE PHYSICAL ACCESS to A.

If you want the total, complete scenario:

I am away at college, and work as a systems programmer for the university. The dorms / residential network is behind a NAT router which (obviously) doesn't allow incoming connections (to my dorm computer, herein "A"). I want to be able to access my dorm computer (A) from work (B), which has a university-wide IP.

So what I need is to be able to somehow connect from A at the dorm to B at work in the morning, then go to work (using computer B), and be able to send files (or, maybe, get a shell) back to A at home (dorm).
Old 10-17-2006, 12:48 AM   #6
Registered: Mar 2005
Location: India
Distribution: Debian
Posts: 368

Rep: Reputation: 37
What about using rsync, which works over ssh.

Old 10-17-2006, 12:10 PM   #7
LQ Newbie
Registered: Oct 2005
Location: Egliswil, Switzerland
Distribution: Slackware
Posts: 2

Rep: Reputation: 0
Use OpenVPN on both side. The server is on your work computer and the client on your home computer. You can have full IP access both directions or if you use iptables you can control access.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
file transfer over ssh? jme Linux - Software 5 11-13-2006 01:30 AM
File transfer program!! vishamr2000 Programming 11 04-27-2006 04:22 AM
SSH File transfer wjeanpaul Linux - General 19 02-07-2006 02:34 PM
File transfer with SSH? Baix Linux - Newbie 5 01-28-2005 06:24 PM
ssh file transfer? Apostasy Linux - Newbie 11 07-30-2004 10:33 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration