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.

This is sort of a level-up from this question. Suppose that I am on computer A and want to send files to a computer C. We each have separate access to a host B. A and C can not communicate directly, and B cannot initiate a connection to either.

Is there a way I could pipe a large file to SSH and create some sort of stream which I could then tell the user of computer C to connect to? The file is larger than the available space on B. My current solution is to split the large file, upload each segment in turn, and when user at C has finished downloading one chunk notifies me, I delete the chunk and upload the next one.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

If I understand you correctly, you want to send data from A to C, but neither computer can connect to the other, but they can both connect to B. B can't connect to anyone.

One solution is using port forwarding. C can forward from a port on B to their SSH port (port 22):

ssh -R 1088:localhost:22

1088 is arbitrary, choose a port that isn't already in use. By default this port is only available on that local machine, i.e., only processes running on B can connect to it.

now a user on A can connect directly to C:

ssh B "ssh -p 1088 localhost"

Or for example, this command will send a file from A to C:

cat infile | ssh B "ssh -p 1088 localhost \"cat > outfile\""

Alternatively, A could have forward their port, allowing the user on C to initiate the copy.

Another solution is to use named pipes. On B, execute:

mkfifo named_pipe

Then on A you can send data into the pipe with:

cat infile | ssh B "cat > named_pipe"

This command will hang until someone opens the other end of the pipe and reads the data out of it. For example, the user on C can do:

ssh B "cat named_pipe" > outfile

This will send the file from A through B to C.

share|improve this answer
add comment

Yes, you can create a named pipe for them to pull. Make sure to create the pipe first, have them connect from computer C, and then start streaming to it.

share|improve this answer
add comment

Your Answer

 
discard

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.