HomePage :: CitrixReplacementUsingRemoteVNC :: RemoteFileSharingWithVNC

Remote Filesharing Via SSH

It seems to me that the easiest method of SMB -sharing via ssh over the Internet is to set up Samba on each end of the link, and forward ports between the two endpoints.

Let's say we have a main office and a remote office, and the remote office needs to access files on a windows network at the main office. Each location is running Linux firewall. The main office's IP address is 1.2.3.4, and the remote office's IP address is 5.6.7.8. Each office is on a private class-C network. The Samba server at the main office has an IP of 192.168.1.30.

The first issue we need to address is NetBIOS browsing, via Network Neighborhood, etc. It is really not possible to do this when using ssh remotely. We'll have to come up with some other way of accessing remote workstations.

But what if we need to access files on Mary's Windows workstation in Accounting at the main office? Here we need to tell the Samba server at the main office about Mary's files, mounting them on the Linux file server via smbmount. Once we have done that, we can treat Mary's files as it they were located on the Linux server. It might be helpful to think of the Linux server in the main office as an SMB proxy that allows us to access the individual workstations.

At the remote office, we ssh to the main office firewall as root and forward the relevant SMB ports:
ssh -C -L 137:192.168.1.30:137 -L 139:192.168.1.30:139 1.2.3.4
We can then sit at Becky's Windows workstation at the remote office and connect to the firewall. Since the firewall has ports 137 and 139 forwarded to it via ssh, we can access it from a Windows workstation even though we don't have Samba running on it. We might have to specify the UNC, as opposed to finding it in Network Neighborhood.

However, since we are running a Samba server at the remote office, we can mount the forwarded ports that are on the firewall. Once we've done that, we can then tell the Samba server to re-export them for the benefit of the users in the remote office.

Accessing Remote Files While Using VNC

Once we are able to access the main office files from the remote office, the next logical thing is to extend this to remote VNC usage.

Let's say we are working on a file on the Samba server at the main office. If we need to have access to the file (say to save it to a floppy on Becky's workstation), we use Windows Explorer on Becky's workstation to access the file via the Samba server on the local LAN. The file actually resides on the main office LAN, we are editing it remotely using Microsoft Word via VNC, and we save it to the floppy via the SMB-and-ssh connection we established earlier, treating the file as local to the remote office LAN for copying purposes.

But what if we need to print the file, instead of just copying it to a floppy? We can do this through Windows Explorer, just like we did for copying, or we can use the alternate method I described on the RemotePrintingWithVNC page, which allows us to print from inside our VNC session.