All network shares in Windows are specifically connected for the current user's session. By default, the Resilio Connect Agent runs as a service in system session as the "Local SYSTEM" or "Local Service" user. As a result, the Agent is unable to see any mapped network drives that are normally seen by the current user account. Additionally, when accessing the UNC path, the Agent tries to supply the credentials of the "Local SYSTEM" or "Local Service" to the SMB server and gets rejected.
This is a Windows OS limitation which can be bypassed using the following three methods:
- Mapping a network drive automatically using a script job
- Mapping a network drive manually using the PSEXEC tool
- Changing the user account running the Agent to one that has access
The script you place in a Script Job gets executed by the Agent, runs in the same system session as the Agent, and therefore accesses the network resource with the proper credentials making it visible to the Agent.
Network share credentialsThis method requires the Management Console Admin to have the credentials to access the network share. If this is not possible, there's a different way to accomplish this.
Please follow the steps below to make sure the network share is accessible to the Agent:
Create a new "Run script" job
Make sure that you only add the Agents that need to access the specified network share. The actual directory is not important (though you should make sure that you pick one that exist on target machine).
Copy the following script and make sure that you select CMD in RUN AS selector:
net use \\<yourservername>\<foldername> /persistent:yes /user:<username> <password>
Save the job and run it. Once the job completes, open the log, and verify that the operation was successful, otherwise the error code will help you to understand why
net use command has failed
If you no longer want the Agent to access the network drive, follow the same steps, but this time place a different script in step3:
net use \\<yourservername>\ /DELETE
Using the PSEXEC utility allows you to login directly to the system session and manage network resources. This is done locally, and will also allow but not reveal the network share credentials to Management Console Administrators.
Make sure that the Agent is running under the "Local System" account
- Open Services, find "Resilio Connect Agent Service"
- Right-click and pick "Properties" -> "Log on"
- Check that either the "Local System account" radio button is selected or "This account" contains "NT AUTHORITY\System" or "Local System" or any other localized username that indicates that the user name is the "Local System". Note that the "Local System" account always has an empty password.
Open the command line with the elevated privileges (Run as Administrator)
Download Sysinternals set of tools , unpack them in a directory, then navigate your Admin command line to the same directory.
In the Admin command line, run the command
psexec -i -s cmd.exe. This will open a new command prompt, running from the System account name. Verify that by running the
whoami command. The output should be
Run the command
net use <drive_letter>: \\<yourservername>\<foldername> <password> /user:<username> /persistent:yes for each drive that needs to be mapped, replacing the drive letter, network path, username, and path accordingly
The mapped drive is going to be visible to all users in your system, though will always show up as "Disconnected" in Explorer.
Disconnect network drive
To disconnect network drive, you'll need to repeat step #2..4 and run the following command in System user command prompt:
net use <drive_letter>: /delete
This way implies running Agent as a user account which name and password matches the one configured on SMB/CIFS server. Therefore, Agent will automatically login to SMB/CIFS server upon first attempt to reach files.
New user permissionsIf you plan the Agent to also access local files, don't forget to grant new user permissions to relevant directories
Please follow the steps below to configure agent running as a different user account.
Find username or create a user on your SMB/CIFS server that you'll use for access.
Create a user with the same name and same password on a computer running agent. You can skip this step is the user you are going to use is a domain user and the computer is part of the domain.
Open permissions of the folder
C:\ProgramData\Resilio\Connect Agent (or
C:\ProgramData\Resilio\Connect Server for Management Console Agent) and add new user with full access there.
And hit okay till you close the folder properties dialog
Open Services, find "Resilio Connect Agent Service" service (Resilio Connect Server if you apply it for Management Console Agent) and open it's properties, "Log on" tab. Enter your user name and its credentials
Once you click "OK", windows may give you a notice that this user is granted a permission to run as service.
Restart the agent service so it will run under new user account. First start as a new user may take a while as Windows will create a new registry hive and new user home directory structure.