How to connect to a remote server using "net use" with different port other than 445
Solution 1
\\<ServerName>\IPC$\Share /user:<domain>\<userName> '<password>'
The key was to use IP before the C$ I got the help from https://klyavlin.wordpress.com/2012/09/19/robocopy-network-usernamepassword/ There is a note mentioned in the the article that you need to share the folder on both server. However if you are running the robocopy on source server then you don't have to share the folder. Example given below.
robocopy C:\Source \\<ServerName>\Foldername /E /MIR /XA:H /R:1 /W:1
Solution 2
If you have control of the remote server and it is a windows server, then try running the following from an elevated (run as administrator) command prompt on the remote server:
netsh a s a state off
Do not leave it in this state as it will turn off the firewall completely to allow you to test. Then try your net use
command again on the client. If this works, then it is a firewall problem. Turn the firewall back on:
netsh a s a state on
Then resolve the firewall issue by adding an appropriate rule (for TCP 445), or change the profile of the network.
Other answers suggest TCP port 139
, but for SMB this is only needed if you will access the machine by its NETBIOS name. It is used for name resolution even when SMB protocol is used. In fact, in that case you made need TCP ports 137-139
open. The actual share access is done via TCP port 445
(since Windows 2000!) and if you will only access the machine via IP then that is the only port that will be used.
However, temporarily turning off the firewall as I suggest will tell you if it is a port/firewall issue.
Solution 3
It may have something to do with SID compression on Windows 2012 servers in connection with older NASes - but if thats what hurts you depends on your particular configuration. I stumbled upon it after specific update was installed on DCs (2012R2), after which I couldn't access SMB shares on older Thecus NAS. There was no kerberos authentication (checked with klist command). Here is the solution: https://support.microsoft.com/en-us/help/2774190/resource-sid-compression-in-windows-server-2012-may-cause-authorization-problems-on-devices-that-do-not-support-resource-sid-compression
Related videos on Youtube
Vikram Shetty
Updated on September 18, 2022Comments
-
Vikram Shetty almost 2 years
The code I am using
net use K: \\<ServerName>\C$\Share /user:<domain>\<userName> '<password>'
K: is the mounted drive
Share is the folder name in server that is shared with userName and password
There error I get is
System error 5 has occurred. Access is denied.
I think the error is because the port 445 is closed in the remote server. Since I am sure I am giving right credentials.
-
Vikram Shetty over 7 yearsIs the the TCP port that I need to open?
-
Alexandre Roux over 7 yearsYes I guess as net use should use 139 and 445.
-
Alexandre Roux over 7 yearsIn order to verify if both of these port are open I recommend you to use : telnet hostname 139 and telnet hostname 445
-
Vikram Shetty over 7 yearsSurprisingly both server is connected via 139 and 445 from Source and Destination and visa-versa
-
Alexandre Roux over 7 yearsHumm ok. Now what about your user NTFS permission on the CIFS that you try to access?
-
Vikram Shetty over 7 yearsOk I guess I got this, Do you mean ntfs.com/ntfs-permissions-setting.htm then the user has full rights to the folder
-
Alexandre Roux over 7 yearsAccess to a folder on a file server can be determined through two sets of permission entries: the share permissions set on a folder and the NTFS permissions set on the folder. You have to make sure that your user is come from a group that have permission to browse the CIFS or the user have permission directly on the CIFS however you will have access denied.
-
Alexandre Roux over 7 yearsI updated my response with the set of permission if it's help you Vikram.
-
Vikram Shetty over 7 yearsI got your answer and I see both share and security have permission to the user. However I still got the issue and I am little clueless about CIFS. :-(
-
Vikram Shetty over 7 yearsLet us continue this discussion in chat.