Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a share setup using samba which requires username/password combination to access the files kept on it.

The script that needs to access this share is running on a windows server as a scheduled task (as a service account) and therefore there is no interactive session present.

I do not want to add steps to the script to mount the share as a drive letter or access it over a UNC path as this will require putting the username and password for the share in clear text in the script. Not great for security.

Does anyone know of a method of mounting a windows(samba) share permanently for a particular windows user so that scheduled tasks running as that user can access the data without the script having to mount it each time the script runs?

I don't want to remove the user/pass authentication to the share and I don't want to put the user/password in clear text in the script itself.



share|improve this question
Why not just assign the rights to the service account that the task is running as? – Shane Madden Aug 22 '11 at 15:51
up vote 1 down vote accepted

It's not clear to me whet ever this is an option to you, but this is what I do on my Windows machines and Samba-based NAS:

  1. Create a local account on the Windows box, with the same username and password as needed to access the Samba share
  2. Run the task using the newly created account. It should be allowed access.
share|improve this answer

The only real solution(s) available to you:

1) Join your linx machine to the domain, and grant a domain user rights on that share. On your windows system, have the scheduled task run as that user. A bit heavy and very ugly if you're happy with your system setup overall (except for this one issue)

2) use something like SCP and SSH Key authentication, which eliminates username/password. PuTTY is a nice freeware SSH/SCP client. A quick googling gave me these rules, most of which look approximately correct (pick the one that makes the most sense to you),or.r_gc.r_pw.&fp=d8edafa9e328c069&biw=1480&bih=933

share|improve this answer

I found this question while looking for how to mount a share from a script. I see that you have qualms about writing the password in the script, but for anyone who doesn't, the command you want is net use.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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