LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Program to transfer file 'backwards' over SSH (https://www.linuxquestions.org/questions/linux-networking-3/program-to-transfer-file-backwards-over-ssh-492692/)

jantman 10-15-2006 05:57 PM

Program to transfer file 'backwards' over SSH
 
Background:

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?

Thanks,
Jason

ilikejam 10-15-2006 06:33 PM

Hi.

Two ways to do this:

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

2)
Code:

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

Brian1 10-15-2006 06:39 PM

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

Brian

chadl 10-15-2006 07:42 PM

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

Code:

scp chadl@example.com:foo.bar .
would get the file from example.com to the local system

Code:

scp foo.bar chadl@example.com:.
will get the file from the local system, and put it on example.com.

jantman 10-16-2006 11:03 PM

Quote:

Originally Posted by Brian1
Check into the -R option for ssh. It allows reverse mapping. Might be what you are after.

Brian

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).

prasanta 10-17-2006 12:48 AM

What about using rsync, which works over ssh.

--
Prasanta

joshartman 10-17-2006 12:10 PM

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.


All times are GMT -5. The time now is 05:15 AM.