[linux-cifs-client] Inconsistent behavior of smbclient/mount.cifs on Port 139 vs. 445 when tunnelling over SSH

Jeffrey J. Kosowsky jeff at kosowsky.org
Wed Dec 13 22:16:54 GMT 2006


Situation as follows:
    Remote client = Windows XP
    Server = Linux
I ssh from Remote Windows XP machine to the Linux server.

I would like to mount my remote windows partition on my Linux server.
After MUCH experimenting, I have noticed the following hard to
understand behavior:

- When not using an SSH tunnel, both 'smbclient' and 'mount.cifs' work
  over either port 139 or 445

- When using smbclient over an SSH tunnel, it only works over port 139

- Conversely, when using mount.cifs over an SSH tunnel, it only works
  over port 445

- When using SSH, smbclient works only with remote port forwarding to
  <remote Windows name> while mount.cifs works only with remote port
  forwarding to 127.0.0.1.
  However, if the 2 machines are on the same network then smbclient
  will also work using 127.0.0.1 (but mount.cifs won't work with
  <remote Windows name>)

- When using SSH, smbclient requires an address of form 
  '//<remote name>/sharename' while mount.cifs requires addresses of form
  '//127.0.0.1/sharename 

- Smbclient will also work substituting  '//127.0.0.1' or
  '//<Remote IP>' for '//<remote name>' but gives an error message:
        "Called name not present"
  However, mount.cifs only works with '//127.0.0.1' (you can't even
  use '//localhost')

So basically, I have 3 questions:
  1. Why doesn't smbclient work over port 445 when using SSH?
  2. Why doesn't mount.cifs work over port 139 when using SSH?
  3. Why does smbclient require forwarding to <remote_name> while
     mount.cifs requires forwarding to 'localhost'

---------
Here are more details of all the permutations I have tried:
       (1) 'smbclient' vs. 'mount.cifs'
       (2) Ports 139 vs. 445
       (3) For port forwarding I have tried all the following combinations
                -R xxxx:localhost:yyy
                -R xxxx:127.0.0.1:yyy
                -R xxxx:<remote name>:yyy
                -R xxxx:<remote IP>:yyy
            where yyy=139 or 445, respectively
       (4) When calling smbclient or mount.cifs from the Linux server,
           I have tried all of the following combinations:
                //<remote name>/sharename
                //<remote IP>/sharename
                //localhost/sharename
                //127.0.0.1/sharename


I then observed that only the following combinations work:
SMBCLIENT
(A) smbclient
    Port 139
    -R xxxx:<remote name>:139      
    //<remote name>/sharename

(B) Same as (A) but with: 
    //127.0.0.1/sharename
        or
    //<remote IP>/sharename
    This works but gives an error message "Called name not present"

(C) If the remote Windows machine and the Linux server on the 'same'
    network, then 'smbclient' also works if you use:
       -R xxxx:localhost:139 or  -R xxxx:127.0.0.1:139

(D) If no SSH then smbclient works on either port 139 or 445

-----------
MOUNT.CIFS
(E) mount.cifs
    Port 445
    -R xxxx:localhost:445   or -R xxxx:127.0.0.1:445
    //127.0.0.1/sharename  (note you can't use //localhost/sharename)
     
(F) If the remote Windows machine and the Linux server on the 'same'
    network, then 'mount.cifs' also works if you use:
    -R xxxx:<remote_name>:445 or -R xxxx:<remote_IP>:445
     //<remote_name>/sharename


More information about the linux-cifs-client mailing list