How to make Windows 7 remember credentials for a Samba network drive?

23,521

Solution 1

This issue bothered me for ages. What finally fixed it was the following:

  1. Disconnect any existing mapped drives
  2. Map a new drive; check the boxes for "Reconnect" and "Use different credentials"
  3. When you are prompted, enter SERVER\USERNAME for the user name. For example, if your server's name is SHIRE, and the user name is Baggins, enter SHIRE\Baggins for the user name.
  4. Enter the password as usual.
  5. Check the "remember credentials" box.

If I understand correctly, some whacky security policy is wiping out the credentials because you're not authenticating against a windows domain. Adding the server name tricks Windows into thinking there's a domain there, and so it dutifully remembers the password. Or something.

Big shout out to Microsoft for this. Well done. /sarcasm

http://alinconstantin.blogspot.com/2009/10/windows-7-cannot-access-smb-shares-on.html

http://alinconstantin.blogspot.com/2010/03/network-shares-on-smb-server-could-not.html

For what it's worth, I tried several other things before this, and I don't know if any of them had an effect. See these blog entries for details:

Solution 2

It turns out you CANNOT use password, /user and /savecred at the same time.. So you need to do:

net use S: \\192.168.1.22\myshare /SAVECRED /PERSISTENT:YES

and it will ask you for your username and password. make sure to use the domain\username syntax for the username! (Use 2 backslash chars in front of the IP address.)

Solution 3

I've had this problem, and I've solved it adding the logon credentials to the Control Panel / Stored User Names and Passwords (this is for a Windows XP / Windows Server 2003 host. There's the same thing in Windows 7 / Windows Server 2008 but it may be called a little different, like just "Users and Passwords". Sadly I don't have an English Windows 7 host at the moment).

You can also obtain the same results with the command line using net use. For example if you need to add a share called SHIRE\Baggins (@Will Martin nice example! :) ) to a device called S: you type:

net use S: \\SHIRE\Baggins <password> /USER:<domain>\<user> /SAVECRED /PERSISTENT:YES

(<password> <domain> and <user> are obviously just placeholders for the actual logon data.)

This should mount the share AND add the logon credentials to the "Stored User Names and Passwords" control panel applet.

I hope this helps.

Solution 4

I had to work through this issue as well. Below is my environment and solution.

Environment:

  • samba share on Ubuntu 12.04
  • Ubuntu server was not in the same domain as other computers on the corporate network
  • Because of the above restriction a dns entry could not be created
  • Authentication had to be local to the Ubuntu server due to not being on the domain and unable to connect to corporate authentication protocols
  • Since we needed to map the drive on many Windows 7 corporate computers the solution had to be in script form

Solution:

  • bat file with the following two statements (text preceded by $ are variables you will need to replace)

cmdkey /add: $serverIP /user:$serverIP\$unixAccoutnName /pass:$password

net use $driveLetter: /d

net use $driveLetter: \$serverIP\$shareName /savecred /persistent:yes

You will need to reboot or log off then back on for the credentials to be picked up.

Share:
23,521

Related videos on Youtube

Marios Pittas
Author by

Marios Pittas

Updated on September 17, 2022

Comments

  • Marios Pittas
    Marios Pittas over 1 year

    I have a Samba share on my Ubuntu server which I map as a network drive on my Windows 7 Professional computer.

    After every reboot it shows the drive as disconnected and to access it I have to renter my password even though every time I enter the password I check the 'Remember my credentials' box.

    Is there way to have Windows 7 remember the credentials on a reboot/shutdown or is it just to remember them per session?

  • Martin J.H.
    Martin J.H. over 10 years
    Alternative method: Instead of deleting and re-mapping all network drives, you can use the "Credential Manager". If it already contains something like "MyComputerName\Baggins", then edit it to "SHIRE\Baggins". If nothing is present, just add "SHIRE\Baggins".
  • user1445967
    user1445967 over 10 years
    I tried this syntax on Windows 7 ultimate and it reports that the switches used are contradictory: net use Z: \\computername\sharename paswrd /USER:computername\username /SAVECRED /PERSISTENT:YES
  • IMTheNachoMan
    IMTheNachoMan over 7 years
    Adding to the credential manager in Windows 7 worked for me!
  • Axel Latvala
    Axel Latvala almost 5 years
    Thank you, fine sir!