Samba: Difference between revisions
imported>Ozkutuk Add section regarding mounting CIFS share as user |
imported>Milahu add ipv4 localhost to hosts allow, add some troubleshooting commands |
||
| Line 101: | Line 101: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.samba-wsdd.enable = true; # make shares visible for windows 10 clients | |||
services.samba = { | services.samba = { | ||
enable = true; | enable = true; | ||
| Line 111: | Line 112: | ||
#use sendfile = yes | #use sendfile = yes | ||
#max protocol = smb2 | #max protocol = smb2 | ||
hosts allow = 192.168.0 | # note: localhost is the ipv6 localhost ::1 | ||
hosts allow = 192.168.0 127.0.0.1 localhost | |||
hosts deny = 0.0.0.0/0 | hosts deny = 0.0.0.0/0 | ||
guest account = nobody | guest account = nobody | ||
| Line 318: | Line 320: | ||
==Troubleshooting== | ==Troubleshooting== | ||
=== Server log === | |||
<pre> | |||
sudo journalctl -u samba-smbd.service -f | |||
</pre> | |||
=== Stale file handle === | === Stale file handle === | ||
Trying to read the contents of a remote file leads to the following error message: "Stale file handle". If you have mounted a share via the method described in "cfis mount", adding the option <code>noserverino</code> might fix this problem. [https://askubuntu.com/questions/1265164/stale-file-handler-when-mounting-cifs-smb-network-drive-from-fritz-router] | Trying to read the contents of a remote file leads to the following error message: "Stale file handle". If you have mounted a share via the method described in "cfis mount", adding the option <code>noserverino</code> might fix this problem. [https://askubuntu.com/questions/1265164/stale-file-handler-when-mounting-cifs-smb-network-drive-from-fritz-router] | ||
== | === List shares === | ||
<pre> | |||
smbclient --list localhost | |||
</pre> | |||
This should print | |||
<pre> | |||
$ smbclient --list localhost | |||
Password for [WORKGROUP\user]: | |||
Sharename Type Comment | |||
--------- ---- ------- | |||
public Disk | |||
IPC$ IPC IPC Service (smbnix) | |||
SMB1 disabled -- no workgroup available | |||
</pre> | |||
=== NT_STATUS_INVALID_NETWORK_RESPONSE === | |||
The error | |||
<code>protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE</code> | |||
means "access denied". | |||
Probably you must fix your server's <code>hosts allow</code> section. | |||
Note that <code>localhost</code> is the ipv6 localhost <code>::1</code>, | |||
and <code>127.0.0.1</code> is the ipv4 localhost | |||
=== Mount shares === | |||
mount as guest. <code>public</code> is your share name | |||
<pre> | |||
nix-shell -p cifs-utils | |||
mkdir mnt | |||
sudo mount.cifs -o sec=none //localhost/public mnt | |||
</pre> | |||
mount as user. <code>user</code> is your username | |||
<pre> | |||
sudo mount.cifs -o sec=ntlmssp,username=user //localhost/public mnt | |||
</pre> | |||
<code>sec=ntlmssp</code> should work. | |||
for more values, see `man mount.cifs` (search for `sec=arg`) | |||
=== Permission denied === | |||
Maybe check the <code>guest account</code> setting in your server config. | |||
The default value is <code>nobody</code>, | |||
but the user <code>nobody</code> has no access to <code>/home/user</code>: | |||
<pre> | |||
$ sudo -u nobody ls /home/user | |||
[sudo] password for user: | |||
ls: cannot open directory '/home/user': Permission denied | |||
</pre> | |||
As workaround, set <code>guest account = user</code>, | |||
where <code>user</code> is your username | |||
== See also == | |||
* [https://search.nixos.org/options/?query=services.samba Samba Options in NixOS] | * [https://search.nixos.org/options/?query=services.samba Samba Options in NixOS] | ||
* [https://wiki.archlinux.org/title/Samba Samba in the Arch Linux Wiki] | |||
[[Category:Services]] | [[Category:Services]] | ||