Inconsistent behavior of smbclient/mount.cifs on Port 139 vs. 445 when tunnelling over SSH
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
- 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
- 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
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:<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:
I then observed that only the following combinations work:
-R xxxx:<remote name>:139
(B) Same as (A) but with:
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
-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