FlexMcMurphy
Posts: 44
Joined: Mon May 19, 2014 3:47 pm

Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Wed Oct 11, 2017 10:14 pm

Hello,

I've spent days on this and hours researching what others have tried but no joy.

I've got Samba 4.5.8-Debian running on Raspbian [GNU/Linux 9.1 (stretch)]. I am trying to connect to a shared folder on the Raspbian OS by connecting from Windows 7 (Home Premium). I get a pop up username/password log-in box but it never authenticates me. I've tried dozens of permutations of the settings in smb.conf and even made registry changes. Nothing has worked!

I have tested accessing the share from an Ubuntu machine and it does authenticate.

Here is my smb.conf file. It does allow an Ubuntu machine access the share but not a Win 7 Home Premium client:

Code: Select all

# Global parameters
[global]
        log file = /var/log/samba/log.%m
        max log size = 1000
        syslog = 0
        panic action = /usr/share/samba/panic-action %d
        usershare allow guests = Yes
        map to guest = Bad User
        obey pam restrictions = Yes
        pam password change = Yes
        passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
        passwd program = /usr/bin/passwd %u
        server role = standalone server
        unix password sync = Yes
        dns proxy = No
        idmap config * : backend = tdb

[NextCloudPi]
        path = /var/www/nextcloud/data/admin/files
        create mask = 0770
        directory mask = 0771
        force create mode = 0660
        force directory mode = 0770
        force group = www-data
        read only = No
        valid users = pi
If I put [guest = ok] in the [NextCloudPi] share definition it lets me straight in to the share without prompting for username/pwd and I can then browse the files in the share but I want to get the authentication working.

I checked with smbpasswd and the [pi] Samba user does exist both in Samba and in the Raspbian OS and I even changed the pwd to be sure I am using the correct one from the Windows log-in pop up.

Here is the error I get:

Image

Other things I tried:
1. Updated the /etc/hosts file in Win 7 to map the (fixed) ip address of the pi to its hostname: nextcloudpi
2. Open regedit and navigate to HKLM\SYSTEM\CurrentControlSet\Control\Lsa then choose to create DWORD named LmCompatibilityLevel then set the value to 2 although value 1.
3. HKLM\System\CCS\Services\LanmanWorkstation\Parameters
DWORD DomainCompatibilityMode = 1
DWORD DNSNameResolutionRequired = 0

From my reading there could be a hundred different things that would work for someone else but not for my setup. Nevertheless I would be very grateful for any help or assistance.

Cheers,

Flex

hortimech
Posts: 111
Joined: Wed Apr 08, 2015 5:52 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Thu Oct 12, 2017 7:56 am

Does the user 'pi' exist on the windows pc ? with the same password ?
Or are you trying to connect as a different user ?
If this is the case, it isn't going to let you in because of 'valid users = pi'

From 'man smb.conf' :

valid users (S)

This is a list of users that should be allowed to login to this
service.

This means that only user 'pi' can login.

I would also remove 'force group = www-data' from the share and add 'security = user' to the [global] section.

User avatar
thagrol
Posts: 280
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Thu Oct 12, 2017 3:14 pm

Can't speak specifically for windows 7 but on other versions I've used (3.11, 95, 98, XP, 8, 8,1 ,10) the windows user name does not have to match the user name on the server. It's quite possible to user different names for the wiondows logon and the server logon.

The second part of that error message suggest that you have tried connecting with two different usernames at the same time, perhaps as a guest and "pi". Windows doesn't allow this but samba does.

There is a way to fool windows into allowing this: set up one or more netbios aliases in smb.conf
For example:

Code: Select all

[global]
	netbios name = foo
	netbios aliases = bar baz
Your server then appears as three servers, when you need simultaneous access, just connect to a different alias.

FlexMcMurphy
Posts: 44
Joined: Mon May 19, 2014 3:47 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Thu Oct 12, 2017 7:02 pm

hortimech wrote:
Thu Oct 12, 2017 7:56 am
Does the user 'pi' exist on the windows pc ? with the same password ?
Or are you trying to connect as a different user ?
If this is the case, it isn't going to let you in because of 'valid users = pi'

From 'man smb.conf' :

valid users (S)

This is a list of users that should be allowed to login to this
service.

This means that only user 'pi' can login.

I would also remove 'force group = www-data' from the share and add 'security = user' to the [global] section.
No the user pi doesn't exist on the Windows pc. I don't think that matters. But I created a new UNIX and Samba user on the Pi with same name and password as the account I always log in from on the PC and tried logging in with this to the Samba share but got no success. Removing force group... and security = user didn't help either.

thagrol wrote: The second part of that error message suggest that you have tried connecting with two different usernames at the same time, perhaps as a guest and "pi". Windows doesn't allow this but samba does.

There is a way to fool windows into allowing this: set up one or more netbios aliases in smb.conf
For example:

Code: Select all

[global]
	netbios name = foo
	netbios aliases = bar baz
Your server then appears as three servers, when you need simultaneous access, just connect to a different alias.
I am only one person using Samba so it was just me trying to log-in one time. I tried the netbios thing but it still would not authenticate.

Any more suggestions people !

Thank you!

Flex

hortimech
Posts: 111
Joined: Wed Apr 08, 2015 5:52 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Thu Oct 12, 2017 8:19 pm

The 'netbios' name has nothing to do with any username, so having an alias for it isn't going to help.

The way Samba works is this, you connect to the share, at which point you need to authenticate to samba. The way smb.conf was set up, the only user that could connect was 'pi', but you would need to have created a Samba user called 'pi' with the same password as the Unix user 'pi'. If you tried to connect to the share as another user, you would be prompted for a valid Samba username & passwd

What you are trying to setup is known as a standalone server, try reading this Samba wikipage:

https://wiki.samba.org/index.php/Settin ... one_Server

User avatar
thagrol
Posts: 280
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Thu Oct 12, 2017 8:26 pm

Sounds like it may be a windows 7 issue. Not able to help with that directly.

Try cutting your smb.conf file back to the bare minimum then adding options back one at a time until you find the one that stops it working.

Start with something like:

Code: Select all

[global]
	workgroup = MSHOME
	security = user
	encrypt passwords = yes

[NextCloudPi]
        path = /var/www/nextcloud/data/admin/files
        browsable = yes
        read only = no
        
Last edited by thagrol on Thu Oct 12, 2017 8:46 pm, edited 1 time in total.

User avatar
thagrol
Posts: 280
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Thu Oct 12, 2017 8:34 pm

hortimech wrote:
Thu Oct 12, 2017 8:19 pm
The 'netbios' name has nothing to do with any username, so having an alias for it isn't going to help.
No, but the second half of the error message pictured by the op was related to simultaneous logins to the server as different users from the same windows session. The netbios aliases thing does help with that.

FlexMcMurphy
Posts: 44
Joined: Mon May 19, 2014 3:47 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Thu Oct 12, 2017 10:41 pm

hortimech wrote:
Thu Oct 12, 2017 8:19 pm
What you are trying to setup is known as a standalone server, try reading this Samba wikipage:

https://wiki.samba.org/index.php/Settin ... one_Server
Hello!

I went to that wiki and went through the instructions step by step. On my windows 7 laptop I have Ubuntu running on a virtual machine so I tested accessing the samba shares on the Pi while connecting from Ubuntu and it DOES work as guest or with authentication. So now the smb.conf file is like this...

Code: Select all

[global]
        interfaces = 192.168.1.124/24
        server string = Raspbian on Pi
        log file = /var/log/samba/%m
        server max protocol = SMB2
        map to guest = Bad User
        idmap config * : backend = tdb


[guest]
        path = /srv/samba/guest/
        guest ok = Yes
        read only = No


[demo]
        path = /srv/samba/demo/
        read only = NO
However when I try to connect from Windows 7 Home Premium I get the log-in pop-up window that says: Logon Failure. Unknown username or bad password.

So the problem must be with the Windows client. I already googled a lot about reports of problems with Win 7 Home Premium and having to change various settings hence me messing with the registry. Overall I still have no idea what the problem is.

Any further help mucho appreciated.

Flex
Attachments
Capture2.JPG
Capture2.JPG (41.17 KiB) Viewed 467 times

User avatar
thagrol
Posts: 280
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Fri Oct 13, 2017 9:40 am

Try logging in via the "use another account" button. Judging by your screen grab, windows will be trying to login with the userid of the current windows session. If that doesn't match a valid samba user id it will fail.

I'm betting that it works from ubuntu because that askz for both a user name and a password.

hortimech
Posts: 111
Joined: Wed Apr 08, 2015 5:52 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Fri Oct 13, 2017 4:42 pm

thagrol wrote:
Thu Oct 12, 2017 8:34 pm
hortimech wrote:
Thu Oct 12, 2017 8:19 pm
The 'netbios' name has nothing to do with any username, so having an alias for it isn't going to help.
No, but the second half of the error message pictured by the op was related to simultaneous logins to the server as different users from the same windows session. The netbios aliases thing does help with that.
No it doesn't , the alias is just that, an alias. You will connect to the 'netbios' name even if you think you are connecting to the 'alias'

hortimech
Posts: 111
Joined: Wed Apr 08, 2015 5:52 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Fri Oct 13, 2017 4:44 pm

Try adding 'server max protocol = NT1' to the [global] section of your smb.conf and restart Samba.

User avatar
thagrol
Posts: 280
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Fri Oct 13, 2017 5:23 pm

hortimech wrote:
Fri Oct 13, 2017 4:42 pm
No it doesn't , the alias is just that, an alias. You will connect to the 'netbios' name even if you think you are connecting to the 'alias'
I beg to differ. From personal experience (and google) windows will connect as different samba users from the same windows session when one samba login uses the netbios name and the other uses a netbios alias. It won't if both use either the name or the same alias.

So while youare actually connect to the same server, using an alias is enough to fool windows into allowing multiple login names on that server.

FlexMcMurphy
Posts: 44
Joined: Mon May 19, 2014 3:47 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Fri Oct 13, 2017 9:10 pm

hortimech wrote: Try adding 'server max protocol = NT1' to the [global] section of your smb.conf and restart Samba.
I tried this... no joy!

thagrol wrote:
Fri Oct 13, 2017 9:40 am
Try logging in via the "use another account" button. Judging by your screen grab, windows will be trying to login with the userid of the current windows session. If that doesn't match a valid samba user id it will fail.

I'm betting that it works from ubuntu because that askz for both a user name and a password.
I only have one login/username on the Windows 7 computer. It's different from [pi]. I'm not sure that you need to have the same username/password to log in to the Windows 7 computer/client AND Raspbian OS/Samba server. But to test this out I created another account on Raspbian which was identical to my Windows 7 account username/password using the instructions here: https://wiki.samba.org/index.php/Settin ... one_Server

.. but still no joy.

I think the problem is more to do with Windows 7 Home Premium. I bet if I tried with Win 7 Pro or Windows 10 computer it would work. Or at least some changes could be made to the local policies that seem to be necessary from my googling but these changes aren't possible or easy under Win 7 Home Premium. Unfortunately I don't have either Win 7 Pro or Windows 10 computers to test.

Well I'm glad to keep trying any other suggestions people have. Thank you for your contributions so far!

Flex

hortimech
Posts: 111
Joined: Wed Apr 08, 2015 5:52 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Sat Oct 14, 2017 10:51 am

OK, try adding 'ntlm auth = yes' to smb.conf.

FlexMcMurphy
Posts: 44
Joined: Mon May 19, 2014 3:47 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Sat Oct 14, 2017 10:52 pm

hortimech you are a GENIUS !!

Finally it works the way it should. I get the log-in box and it authenticates correctly to the Samba share on the Pi. What a relief to finally get that working. I was beginning to think it just wasn't possible with Win 7 Home Premium.

When I was testing I wasn't sure how to disconnect from a Samba share. I'm going to make a batch file with the command...

Code: Select all

net use * /delete
as explained here --> https://superuser.com/questions/352270/ ... omatically

Thanks again to both thagrol and hortimech for helping me solve this problem !

Flex

hortimech
Posts: 111
Joined: Wed Apr 08, 2015 5:52 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Sun Oct 15, 2017 8:38 am

You somehow seem to have NTLMv2 turned off on your Windows 7 PC, it seems to be only sending NTLM and Samba now uses NTLMv2 by default. NTLM is insecure, so it is up to you whether you fix your PC or continue to use NTLM.

FlexMcMurphy
Posts: 44
Joined: Mon May 19, 2014 3:47 pm

Re: Can't connect to Samba running on Raspbian from Windows 7 Home Premium

Sun Oct 15, 2017 4:43 pm

Hello again,

So I'm learning a little more about Samba. I realise this whole mess of mine began because I started with an smb.conf file I've had since 2013 which includes the line:

Code: Select all

max protocol = SMB2
This limits the Samba server to version 2 of the protocol which does not support NTLMv2. Via much confused googling I ended up messing with my Windows registry settings to disable NTLMv2. Why it didn't work after I made those changes might be because I hadn't created and enabled a valid user using smbpasswd in the Raspbian OS running on the Pi that the Samba server is running on.

Anyway I reset the registry DWORD: LmCompatibilityLevel in HKLM\SYSTEM\CurrentControlSet\Control\Lsa to 3
Clients use only NTLMv2 authentication, and they use NTLMv2 session security if the server supports it. Domain controllers accept LM, NTLM, and NTLMv2 authentication.
https://technet.microsoft.com/en-us/lib ... 60646.aspx

... so now my Windows 7 client will only use NTLMv2 authentication with the Samba server. The other change to smb.conf then was to remove max protocol = smb2 completely. The default is smb3 and this version of the Samba protocol does support NTLMv2.

Here is my smb.conf file now. It's different from the original at the start of this thread but it shows how to get authentication working from a Windows 7 client to Samba running as a Standalone Server on Raspbian on a Pi.

Code: Select all

[global]
        workgroup = WORKGROUP
	netbios name = nextcloudpi
        server string = Raspbian on Pi
        interfaces = 192.168.1.124/24
        map to guest = Bad User
        log file = /var/log/samba/%m
        log level = 1

[guest]
        # This share allows anonymous (guest) access without authentication!
        path = /srv/samba/guest/
        read only = no
        guest ok = yes

[demo]
        # This share requires authentication to access
        path = /srv/samba/demo/
        read only = no
        guest ok = no
The ip address of my Pi on which the NextCloudPi server is running is 192.168.1.124.

For authentication to work with the above smb.conf configuration a valid and enabled user is required in the Raspbian OS, on which Samba runs, with the correct access permissions to the "demo" share as explained in this Samba wiki: https://wiki.samba.org/index.php/Settin ... one_Server

So there you have it!

Flex

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 8 guests