I'm missing a piece of this puzzle so I hope someone can help me.

The SETUP: My computer with Windows O/S is behind a NAT/Firewall at work and I can not open any ports to forward. At home I have a Ubuntu Server. I'm able to use a ssh client (putty) to connect from the Windows computer at work to my Ubuntu Server at home. Using port forward in putty, I made a network share on my Windows computer that is connected via smb to a network share on my Ubuntu Server at home.

The Problem: I would like to REVERSE the smb share described above by using a Reverse SSH tunnel connection.

WHAT I MEAN IS: Use Reverse SSH with SMB ports (445) to connect & mount to Windows share (behind NAT) FROM Ubuntu Server.


How would I setup my Reverse SSH tunnel in putty? (again I understand Reverse SSH). Right now under the tunneling option in Putty I have port 445 as my source, localhost:445 as my destination and REMOTE & IPV4 options selected. Is this correct?

Once I get the Reverse SSH tunnel setup correct for SMB, how do I connect and mount a Windows share that is behind the NAT FROM my Ubuntu Server? Same way if Ubuntu Server was to mount share with Windows computer on same Network? sudo mount -t cifs //IPADRESS/WinShare /mnt/UbuntuShare -o username="Username",domain=

If you have any questions please let me know and I will get back to you ASAP!

Thanks, Ben


  • Who is exporting and who is mounting? Your use of "from" is confusing. Is windows exporting via smb or Ubuntu?
    – terdon
    Apr 1, 2013 at 18:14
  • how do I mount a Windows share from a Ubuntu Server. The Window share is on another network and I cannot open any ports on the network that is hosting this windows share. So correct me if I am wrong, but I would setup a Reverse SSH tunnel via putty on the Windows machine and setup portfordwarding in order to access the Windows share on the Ubuntu Server, correct? Apr 1, 2013 at 18:20
  • Ok, so with out any help from this form, I believe I am getting a little closer. I have setup a successful Reverse ssh tunnel to view my Windows laptop webserver that sits behind a firewall on another network from my Ubuntu Server. Putty portforward source:9090 destination localhost:80 and make sure the remote/auto options are clicked. Once resverse tunnel is established from putty (Windows laptop), try wget localhost:9090 from your Ubuntu machine. If you get your files transferred then the reverse ssh to your Windows laptop that sits behind firewall from your Ubuntu Server worked Apr 2, 2013 at 14:38
  • Well done for figuring that out! Could you please post your solution as an answer so others can benefit from it?
    – terdon
    Apr 2, 2013 at 14:40
  • Now that I know Reverse SSH works, how would I get to my Windows share that is on the Windows laptop behind an unaccessable firewall, from my Ubuntu Server? I tried to set putty (plink would work as well) on my Windows machince to portforward source 4445 destination localhost:445, remote button clicked. Then use the command from my Ubuntu Server(connected from putty session): smbclient -L //localhost -p 4445 -U "Username" to list the reverse ssh Windows share. FAILED! Error: read error = NT_STATUS_END_OF_FILE. hmmmm not to sure what this means? Apr 2, 2013 at 14:47

1 Answer 1


Well I figured out the answer to my OWN question. This resolves the question "How to connect to a share using SSH Reverse" If you do not know what SSH Reverse is please disregard this solution!

My setup: Computer A= Ubuntu Server running SSH Server at home. (Diff network)

Computer B= Windows Desktop behind work firewall (cannot open ports) (Diff network)

Like I said, I CANNOT open ports for Computer B and I need Computer A to be able to mount a share (securely) on Computer B .

What this means:To share file between Computer A and Computer B I cannot use FTP,SFTP,or even SSH using port forward because the Ports on Computer B are not open!

HOWEVER, there is a solution to this! Its called SSH Reverse. I won't get to far into this but for my setup Computer A has a SSH Server running on it and Computer B has a client(like putty/plink). Remember to goal is to share files with Computer B from Computer A so in this scenario you MUST you SSH reverse.

So 1st make sure you can communicate/connect with your SSH Server on Computer A with your client (I'm using putty) on Computer B. Works? Great moving on...

Now you need to setup your Reverse Port Forward in putty (on Computer B) by selecting saved connection and going to Tunnel option. Next you need to "Add new port forward".

The source port can be any open port. If your not sure use: 5454. The destination should be: localhost:445 NOTE: destination DOES NOT have to be localhost, in fact localhost may output as "Host Down". It can be any IP on network. Example (your own IP)

Make sure the Remote button and Auto button are selected. Then click Add and make sure you SAVE the settings for that connection before you open that connection. Now connect to your SSH Server (Computer A).

Now don't forget to create a mount folder( any folder that the mount share will show up in).

Now you should be able to mount your share on Computer B with Computer A with out opening any ports.

Example mount code:

sudo mount -t cifs //localhost/sambashare /mountpoint -o port=5454,username="",password="",domain="optional"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.