'Communication between two networks over file share
My problem is that I have two computers in different networks which can "communicate" only over a common file share mounted on both systems (typically Windows SMB server on third-party host). All other ports are blocked! I would like to use this file share for a direct communication between these two machines. I'm root on both machines, it's possible to use Windows or Linux on them. There is also no need to use SSH for the communication, 'netcat' or other command-line oriented tools are available.
What has been done so far to solve it: I started a (long ;-) discussion about tunneling SSH, which is on hold now, SSH: TCP-over-File?, but includes many valuable information (especially from Ch. Duffy et al.). I have understood that SSH is not suitable for that, but the question, if this Windows tunneling tool could by useful, is still open: https://labs.mwrinfosecurity.com/tools/tcp-over-file-tunnel/
How to establish a communication using common tools coming with the operating systems (Ubuntu or Windows 7) in this case?
Solution 1:[1]
Your requirement of common tools excludes any possible Windows solutions.
netcat is a great tool, if you have direct TCP/IP connectivity, which is not the case here.
File redirection is not a concern, since you can redirect locally and pickup on remote; I will assume you are looking for a more elegant terminal as your definition of communication.
You are on the right track using tail -f, but attempting to emulate a network connection would require rewriting SSH to use a file for communication.
My improvement to your code as described in "SSH: TCP-over-file" is to simulate an actual terminal. Run the following code on the local machine in single window:
tail -f /mnt/fileshare/my_ssh_out >>/dev/`ps eax | grep $$ |cut -d ' ' -f 2 | tail -n 1` &
cat >> /mnt/fileshare/my_ssh_in
The line: /dev/ps eax | grep $$ |cut -d ' ' -f 2 | tail -n 1 & gets the current terminal, so the output can be redirected there.
Note: you cannot redirect the output locally.
Solution 2:[2]
So, if you're root on both machines, I'm assuming there's an intermediate firewall you do not control? Between that and the very vague requirement of "communications", I see a few options that aren't terribly fast but could work.
Create 2 folders, one for each machine to drop 'message' files into. Each node would run an app listening for new files (from the other computer) being queued up, download and process new ones, and delete processed messages.
Have one machine running a server (you said they were networked, so I am assuming internet here) with web sockets, and have the other connect to it as a client. You can then pass messages and trigger actions over the web.
Neither of these will be fast or perfectly reliable, and probably wouldn't provide full control over the other computer. You may be limited to pre-defined actions triggered by specific keywords, or you might be crazy enough to pull in arbitrary commands from the messages and blindly execute them under your user permissions.
Solution 3:[3]
If the only segmentation between the computers is IP subnets, for example: no VLANs or physical separation. Try to connect using IPv6 by pinging the link-local addresses.
Use the following Windows command in a cmd window:
ipconfig /all
Look for the "FE80:"... address on the physical adapter.
On the other computer:
ping -6 fe80:...
If this works you may use that IP address to communicate between computers. Each of the VMs will have a different address. In Linux use ifconfig to find the addresses.
If that does not work, you can always use two cheap USB wired ethernet adapters and a crossover cable.
Solution 4:[4]
If You have ssh connection from your workstation to both servers - just use putty for tunneling or something like that.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Strom |
| Solution 2 | brichins |
| Solution 3 | Strom |
| Solution 4 | Andrey |
