Smb windows from linux

Содержание
  1. Smb windows from linux
  2. Mounting and mapping shares between Windows and Linux with Samba
  3. More Linux resources
  4. Подключение к папке Windows из Ubuntu по протоколу SMB
  5. Выдаем общий доступ к файлам на компьютере с Windows
  6. Добавляем компьютер в hosts на Ubuntu
  7. Подключение к папке Windows из Ubuntu. Вариант 1
  8. Подключение к папке Windows из Ubuntu. Вариант 2
  9. Надеемся у вас получилось подключение к папке Windows из Ubuntu
  10. Попробуй бесплатно наши курсы по Linux и devOPS на:yodo.im/start
  11. Samba
  12. Contents
  13. Server
  14. Installation
  15. Enabling and starting services
  16. Configure firewall
  17. Usage
  18. User management
  19. Creating an anonymous share
  20. Enable symlink following
  21. Advanced Configuration
  22. Enable Usershares
  23. Set and forcing permissions
  24. Restrict protocols for better security
  25. Use native SMB transport encryption
  26. Disable printer sharing
  27. Block certain file extensions on Samba share
  28. Improve throughput
  29. Enable access for old clients/devices
  30. Client
  31. List public shares
  32. NetBIOS/WINS host names
  33. Disable NetBIOS/WINS support
  34. Manual mounting
  35. Storing share passwords
  36. Automatic mounting
  37. Using NetworkManager and GIO/gvfs
  38. As mount entry
  39. As systemd unit
  40. smbnetfs
  41. autofs
  42. File manager configuration
  43. GNOME Files, Nemo, Caja, Thunar and PCManFM
  44. Other graphical environments
  45. Tips and tricks
  46. Discovering network shares
  47. Remote control of Windows computer
  48. Troubleshooting
  49. Failed to start Samba SMB/CIFS server
  50. Permission issues on SELinux
  51. Permission issues on AppArmor
  52. No dialect specified on mount
  53. Unable to overwrite files, permissions errors
  54. Windows clients keep asking for password even if Samba shares are created with guest permissions
  55. Windows 7 connectivity problems — mount error(12): cannot allocate memory
  56. Windows 10 1709 and up connectivity problems — «Windows cannot access» 0x80004005
  57. Error: Failed to retrieve printer list: NT_STATUS_UNSUCCESSFUL
  58. Sharing a folder fails
  59. «Browsing» network fails with «Failed to retrieve share list from server»
  60. Protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE
  61. Connection to SERVER failed: (Error NT_STATUS_UNSUCCESSFUL)
  62. Connection to SERVER failed: (Error NT_STATUS_CONNECTION_REFUSED)
  63. Protocol negotiation failed: NT_STATUS_CONNECTION_RESET
  64. Password Error when correct credentials are given (error 1326)
  65. Mapping reserved Windows characters
  66. Folder shared inside graphical environment is not available to guests
  67. Verify correct samba configuration
  68. Verify correct shared folder creation
  69. Verify folder access by guest
  70. Mount error: Host is down
  71. Software caused connection abort
  72. Connection problem (due to authentification error)

Smb windows from linux

Машины с Linux (UNIX) могут также просматривать и монтировать SMB-ресурсы. Заметьте, что это может быть сделано когда сервером является либо машина с Windows, либо с сервером Samba!

Программа клиента SMB для UNIX-машин включена в дистрибутив Samba. Она обеспечивает ftp-подобный интерфейс командной строки. Вы можете использовать эту утилиту для переноса файлов между ‘сервером’ под управлением Windows и клиентом под Linux.

Большинство дистрибутивов Linux также включают полезный пакет smbfs, который позволяет монтировать и размонтировать SMB-ресурсы. Больше информации о smbfs можно получить дальше.

Для того, чтобы увидеть какие ресурсы доступны на данной машине, выполните команду:

где ‘host’ это имя машины, которую вы хотите видеть. Эта команда вернет список имен ‘сервисов’ — т.е. имен дисков или принтеров к которым может быть получен доступ. До тех пор, пока SMB сервер не будет настроен без управления доступом, он будет запрашивать у вас пароль. Введите в ответ на запрос пароль для пользователя ‘гость (guest)’ или ваш персональный пароль на этой машине.

Вывод этой команды должен выглядеть примерно так:

Browse list показывает другие SMB сервера в сети с доступными ресурсами.

Для использования клиента, выполните следующую команду:

где ‘service’ — имя машины и сервиса. Например, если вы пытаетесь обратиться к директории, которая доступна под именем ‘public’ на машине названной ‘zimmerman’, то имя сервиса должно звучать как \\zimmerman\public. Однако в следствии ограничений оболочки, вам необходимо спрятать обратный слэш, так что в итоге это командная строка выглядеть следующим образом:

где ‘mypasswd’ — символьная строка вашего пароля.

Вы получите приглашение smbclient:

Напечатайте ‘h’ чтобы получить помощь об использовании smbclient:

Если вы умеете использовать ftp, то вам не будут нужны справочные страницы о smbclient.

Хотя вы можете использовать smbclient для тестирования, вы скоро устанете использовать его в работе. Для работы вам скорее всего понадобится пакет smbfs. Smbfs поставляется с двумя простыми утилитами, smbmount и smbumount. Они работают подобно mount и umount для SMB-ресурсов.

Одно важное замечание: Чтобы использовать эти утилиты, у вас должна быть поддержка smbfs вкомпилированная в ядро!

Следующий пример показывает типичное использование smbmount для монтирования SMB-ресурса, названного «customers» с машины с именем «samba1»:

Запуск команды mount покажет вам, что ресурс смонтирован, точно также как и через экспорт NFS:

Пожалуйста прочитайте справочные страницы smbmount и smbumount для дополнительной информации о описанных выше операциях.

Источник

Mounting and mapping shares between Windows and Linux with Samba

More Linux resources

In my previous article, Interoperability: Getting started with Samba, I covered installing and configuring Samba shares on a Linux server. The real power of Samba comes when Windows clients can communicate with Linux file servers. In this article, I will cover how you can access Samba shares from both Linux and Windows clients.

Install the Samba client packages

To access Samba share from Linux clients we need to install a few Samba client packages.

On the client machine, install the samba-common and samba-client packages.

Check for available shares

Let’s check if we can access our shares from the server. We can use either the hostname or ip address of the server. If you use the hostname , make sure DNS is working.

Create a directory that we can use as our mount point. I’m going to create a directory under /mnt , but you can use any directory you would like to. You may need to configure SELinux on that directory.

Now, mount the share.

Now that we’ve mounted our share, we can check the mounts with the following command:

Let’s make that directory mount persistently so it can withstand a reboot. Using the text editor of your choice, edit the /etc/fstab file. You can do this in multiple ways, but I’m going to demonstrate two ways to mount the Samba share at boot in /etc/fstab .

The first option provides a username and password for the Samba user in the fstab .

The other option is to create a credential file. You can call this file anything, but I would like to call it cred . I would like to place credentials files in the home directory of the user. In our demonstration it will be /home/user/.cred .

The _netdev option is important since we are mounting a network device. Clients may hang during the boot process if the system encounters any difficulties with the network.

Now create that .cred file inside the user’s home directory.

Next, add the Samba user’s username and password.

Finally, mount all filesystems.

Access a share from a Windows client

I will be using Windows 10 as my client machine with a workgroup called SAMBA . We need to create a local user account on the Windows machine that matches the username and password of the Samba user account we created in my previous article. Although account creation is not necessary, this will make things simpler when accessing the share.

Like I mentioned above, this step is optional and you can skip it completely. Although there are multiple approaches to adding a new local user on a Windows machine, for the simplicity of this article I will be using PowerShell. Launch PowerShell as an administrator and issue following commands:

Now that we have created a new local user account matching the Samba user account, we can log in to Windows with our newly created user account.

Access a share from Windows Explorer

To access the Samba share from Windows Explorer, start typing the IP address to our share in the search area. I am using the hostname of the Samba server. In my case, it is centos . You can also access the share by using the IP address of the Samba server.

You might be prompted to enter the username and password to access the share if you skipped the local user creation process. If you get prompted for credentials, enter the Samba username and password we created in the previous article.

You will need to enter the Samba share path every time you want to access the share. There is a better way to access the share by mapping a drive to Samba share in Windows.

Mapping a drive to a Samba share

To map a drive to the Samba share, open PowerShell and issue following command:

Accessing a Samba share on Linux and Windows is easy. With this basic setup, you will be able to access file shares from client machines in your network. With somewhat more configuration, you can deploy Samba shares in a domain environment. Samba can do more than file share. If you would like to learn more about Samba, read this article about Windows and Linux interoperability. This is a basic set up, but you can do so much more with Samba.

[ Want to test your sysadmin skills? Take a skills assessment today. ]

Источник

Читайте также:  Драйвер запоминающее устройство для usb для windows

Подключение к папке Windows из Ubuntu по протоколу SMB

В сегодняшней статье речь пойдет о подключении к папке (файловому хранилищу) Windows (Samba) из Ubuntu 20.04 Long-Term Support (LTS)

Имеющаяся конфигурация: Компьютер с Windows 10 имеющий локальное доменное имя Halo и статический локальный IP адрес 172.16.0.3. Виртуальная машина с Ubuntu 20.04 и сетью в режиме моста. IP адрес 172.16.0.16.

Выдаем общий доступ к файлам на компьютере с Windows

Для начала убедитесь, что в настройках сетевых подключений у Вас стоит «Частная сеть» Это нужно для того, чтобы доступ работал правильно.

Затем открываем проводник, вкладка этот компьютер, нажимаем правую кнопку мыши по необходимому диску (также работает и с отдельными папками) и нажимаем свойства.

Переходим в раздел Доступ, расширенные настройки общего доступа.

Нажимаем галочку открыть общий доступ, затем идем в разрешения и проставляем необходимые для себя права.

Затем применить и ещё раз применить. Также можно создать отдельного пользователя, для разграничения прав. Аналогично поступаю с диском E.

Продолжаем подключение к папке Windows из Ubuntu.

Добавляем компьютер в hosts на Ubuntu

Открываем терминал на Ctrl + Alt + T, вводим команду sudo gedit /etc/hosts делаем как на скриншоте. Используется табуляция (Tab), а не пробел.

Этим мы пропишем локальное доменное имя компьютера, к которому будем подключаться к его IP адресу, т.к Ubuntu сама по себе не умеет в подобное, в отличие от Windows. Проверим через команду ping Halo. Всё работает как нам нужно.

Подключение к папке Windows из Ubuntu. Вариант 1

Тут мы будем использовать cifs-utils для монтирования сетевой папки в любую папку на Ubuntu.

Устанавливаем пакет командой sudo apt install cifs-utils

Затем командой mkdir mount создаем папку в домашней директории пользователя /home/ , куда будем монтировать сетевую папку.

Командой ls проверяем, создалась ли папка.

Далее воспользуемся командой sudo mount -t cifs -o username= ,password= ,uid=1000,iocharset=utf8 // /директория (у меня открыт доступ к диску D, как просто папка D) /директория где создали папку (/home/yodo/mount в нашем случае).

Названия папок замазаны, т.к это мой личный ПК и мои персональные данные.

Подключение к папке Windows из Ubuntu. Вариант 2

В файловом менеджере нажимаем «другие места»

Вводим в нижнее поле команду smb://

Далее нас приветствует окно входа, вводим данные и пользуемся. Видит и D и E открытые, остальные некоторые глюки программы. На этом всё.

Надеемся у вас получилось подключение к папке Windows из Ubuntu

Попробуй бесплатно наши курсы по Linux и devOPS на:yodo.im/start

Насколько публикация полезна?

Нажмите на звезду, чтобы оценить!

Средняя оценка 4.5 / 5. Количество оценок: 2

Источник

Samba

Samba is the standard Windows interoperability suite of programs for Linux and Unix. Since 1992, Samba has provided secure, stable and fast file and print services for all clients using the SMB/CIFS protocol, such as all versions of DOS and Windows, OS/2, Linux and many others.

To share files through Samba, see #Server section; to access files shared through Samba on other machines, please see #Client section.

Contents

Server

Installation

Samba is configured in the /etc/samba/smb.conf configuration file, which is extensively documented in smb.conf(5) .

Because the samba package does not provide this file, one needs to create it before starting smb.service .

A documented example as in smb.conf.default from the Samba git repository may be used to setup /etc/samba/smb.conf .

Enabling and starting services

To provide basic file sharing through SMB, enable/start smb.service and nmb.service . See smbd(8) and nmbd(8) for details.

Configure firewall

If you are using a firewall, do not forget to open required ports (usually 137-139 + 445). For a complete list, see Samba port usage.

UFW Rule

A Ufw App Profile for SMB/CIFS is included by default with the default installation of UFW in ufw-fileserver .

Allow Samba by running ufw allow CIFS as root.

If you deleted the profile, create/edit /etc/ufw/applications.d/samba and add the following content:

Then load the profile into UFW run ufw app update Samba as root.

Then finally, allow Samba by running ufw allow Samba as root.

firewalld service

To configure firewalld to allow Samba in the home zone, run:

The three service listed are:

  • samba : for sharing files with others.
  • samba-client : to browse shares on other machines on the network.
  • samba-dc : for Samba/Active Directory domain controller.

—permanent ensures the changes remain after firewalld.service is restarted.

Usage

User management

The following section describes creating a local (tdbsam) database of Samba users. For user authentication and other purposes, Samba can also be bound to an Active Directory domain, can itself serve as an Active Directory domain controller, or can be used with an LDAP server.

Adding a user

Samba requires a Linux user account — you may use an existing user account or create a new one.

Although the user name is shared with Linux system, Samba uses a password separate from that of the Linux user accounts. Replace samba_user with the chosen Samba user account:

Depending on the server role, existing File permissions and attributes may need to be altered for the Samba user account.

If you want the new user only to be allowed to remotely access the file server shares through Samba, you can restrict other login options:

  • disabling shell — usermod —shell /usr/bin/nologin —lock samba_user
  • disabling SSH logons — edit /etc/ssh/sshd_config , change option AllowUsers

Also see Security for hardening your system.

Listing users

Samba users can be listed using the pdbedit(8) command:

Changing user password

To change a user password, use smbpasswd :

Creating an anonymous share

1. Create a Linux user which anonymous Samba users will be mapped to.

2. Add the following to /etc/samba/smb.conf :

Any anonymous users will now be mapped to the Linux user guest and have the ability to access any directories defined in guest.path , for example, /tmp/ in the configuration above.

Make sure shares have been properly defined as per the Share Definitions section of smb.conf.default.

Advanced Configuration

Enable Usershares

Usershares is a feature that gives non-root users the capability to add, modify, and delete their own share definitions.

  1. Create a directory for usershares:
  2. Create a user group:
  3. Change the owner of the directory to root and the group to sambashare :
  4. Change the permissions of the usershares directory so that users in the group sambashare can read, write and execute files:

Set the following parameters in the smb.conf configuration file:

Add the user to the sambashare group. Replace your_username with the name of your user:

Restart smb.service and nmb.service services.

Log out and log back in.

If you want to share paths inside your home directory you must make it accessible for the group others.

In the GUI, you can use Thunar or Dolphin — right click on any directory and share it on the network.

In the CLI, use one of the following commands, replacing italic sharename, user, . :

Set and forcing permissions

Permissions may be applied to both the server and shares:

See smb.conf(5) for a full overview of possible permission flags and settings.

Restrict protocols for better security

Append server min protocol and server max protocol in /etc/samba/smb.conf to force usage of a minimum and maximum protocol:

See server max protocol in smb.conf(5) for an overview of supported protocols.

For compatibility with older clients and/or servers, you might need to set client min protocol = CORE or server min protocol = CORE , but please note that this makes you vulnerable to exploits in SMB1 including ransomware attacks.

Clients using mount.cifs may need to specify the correct vers=* , e.g.:

See mount.cifs(8) for more information.

Use native SMB transport encryption

Native SMB transport encryption is available in SMB version 3.0 or newer. Clients supporting this type of encryption include Windows 8 and newer, Windows server 2012 and newer, and smbclient of Samba 4.1 and newer.

To use native SMB transport encryption by default, set the server smb encrypt parameter globally and/or by share. Possible values are off , enabled (default value), desired , or required :

To configure encryption for on the client side, use the option client smb encrypt .

See smb.conf(5) for more information, especially the paragraphs Effects for SMB1 and Effects for SMB2.

Disable printer sharing

By default Samba shares printers configured using CUPS.

If you do not want printers to be shared, use the following settings:

Block certain file extensions on Samba share

Samba offers an option to block files with certain patterns, like file extensions. This option can be used to prevent dissemination of viruses or to dissuade users from wasting space with certain files. More information about this option can be found in smb.conf(5) .

Improve throughput

The default settings should be sufficient for most users. However setting the ‘socket options’ correct can improve performance, but getting them wrong can degrade it by just as much. Test the effect before making any large changes.

Read the smb.conf(5) man page before applying any of the options listed below.

Читайте также:  Assassins creed для linux

The following settings should be appended to the [global] section of /etc/samba/smb.conf .

SMB3 multi-channel may improve performance, however it may result in data corruption under some rare conditions. Future releases may improve this situation:

Setting a deadtime is useful to stop a server’s resources from being exhausted by a large number of inactive connections:

The usage of sendfile may make more efficient use of the system CPU’s and cause Samba to be faster:

Setting min receivefile size allows zero-copy writes directly from network socket buffers into the filesystem buffer cache (if available). It may improve performance but user testing is recommended:

Reading/writing files asynchronously may improve performance instead of using synchronously writes:

Increasing the receive/send buffers size and socket optimize flags might be useful to improve throughput. It is recommended to test each flag separately as it may cause issues on some networks:

Enable access for old clients/devices

Latest versions of Samba no longer offer older authentication methods and protocols which are still used by some older clients (IP cameras, etc). These devices usually require Samba server to allow NTMLv1 authentication and NT1 version of the protocol, known as CIFS. For these devices to work with latest Samba, you need to add these two configuration parameters into [global] section:

Anonymous/guest access to a share requires just the first parameter. If the old device will access with username and password, you also need the add the second line too.

Client

Install smbclient for an ftp -like command line interface. See smbclient(1) for commonly used commands.

For a lightweight alternative (without support for listing public shares, etc.), install cifs-utils that provides /usr/bin/mount.cifs .

Depending on the desktop environment, GUI methods may be available. See #File manager configuration for use with a file manager.

List public shares

The following command lists public shares on a server:

Alternatively, running smbtree will show a tree diagram of all the shares. This is not advisable on a network with a lot of computers, but can be helpful for diagnosing if you have the correct sharename.

Where the options are -b ( —broadcast ) to use broadcast instead of using the master browser and -N ( -no-pass ) to not ask for a password.

NetBIOS/WINS host names

You may need to start winbind.service and nmb.service in order to resolve host names with e.g., mount.cifs

The smbclient package provides a driver to resolve host names using WINS. To enable it, add wins to the “hosts” line in /etc/nsswitch.conf .

If it is not already there, add it to look roughly like this:

You can test WINS resolution with nmblookup . Note that WINS resolution requires incoming traffic originating from port 137.

Disable NetBIOS/WINS support

When not using NetBIOS/WINS host name resolution, it may be preferred to disable this protocol:

Manual mounting

Create a mount point for the share:

Mount the share using mount.cifs as type . Not all the options listed below are needed or desirable:

The options uid and gid corresponds to the local (e.g. client) user/user group to have read/write access on the given path.

  • SERVER — The server name.
  • sharename — The shared directory.
  • mountpoint — The local directory where the share will be mounted.
  • [-o options] — See mount.cifs(8) for more information.

Storing share passwords

Storing passwords in a world readable file is not recommended. A safer method is to use a credentials file instead, e.g. inside /etc/samba/credentials :

For the mount command replace username=myuser,password=mypass with credentials=/etc/samba/credentials/share .

The credential file should explicitly readable/writeable to root:

Automatic mounting

Using NetworkManager and GIO/gvfs

NetworkManager can be configured to run a script on network status change. This script uses the gio command so that it mounts the Samba shares automatically, the same way your file manager does, as explained below. The script also safely unmounts the Samba shares before the relevant network connection is disabled by listening for the pre-down and vpn-pre-down events. Make the script is executable after creating it.

Create a symlink inside /etc/NetworkManager/dispatcher.d/pre-down to catch the pre-down events:

As mount entry

This is a simple example of a cifs mount entry that requires authentication:

As systemd unit

Create a new .mount file inside /etc/systemd/system , e.g. mnt-myshare.mount . See systemd.mount(5) for details.

What= path to share

Where= path to mount the share

Options= share mounting options

To use mnt-myshare.mount , start the unit and enable it to run on system boot.

automount

To automatically mount a share (when accessed, like autofs), one may use the following automount unit:

Disable/stop the mnt-myshare.mount unit, and enable/start mnt-myshare.automount to automount the share when the mount path is being accessed.

smbnetfs

First, check if you can see all the shares you are interested in mounting:

If that does not work, find and modify the following line in /etc/samba/smb.conf accordingly:

Now restart smb.service and nmb.service .

If everything works as expected, install smbnetfs from the official repositories.

Then, add the following line to /etc/fuse.conf :

Now copy the directory /etc/smbnetfs/.smb to your home directory:

Then create a link to smb.conf :

If a username and a password are required to access some of the shared folders, edit

/.smb/smbnetfs.auth to include one or more entries like this:

It is also possible to add entries for specific hosts to be mounted by smbnetfs, if necessary. More details can be found in

If you are using the Dolphin or GNOME Files, you may want to add the following to

/.smb/smbnetfs.conf to avoid «Disk full» errors as smbnetfs by default will report 0 bytes of free space:

When you are done with the configuration, you need to run

Otherwise, smbnetfs complains about ‘insecure config file permissions’.

Finally, to mount your Samba network neighbourhood to a directory of your choice, call

Daemon

The Arch Linux package also maintains an additional system-wide operation mode for smbnetfs. To enable it, you need to make the said modifications in the directory /etc/smbnetfs/.smb .

Then, you can start and/or enable the smbnetfs daemon as usual. The system-wide mount point is at /mnt/smbnet/ .

autofs

See Autofs for information on the kernel-based automounter for Linux.

File manager configuration

GNOME Files, Nemo, Caja, Thunar and PCManFM

In order to access samba shares through GNOME Files, Nemo, Caja, Thunar or PCManFM, install the gvfs-smb package, available in the official repositories.

Press Ctrl+l and enter smb://servername/share in the location bar to access your share.

The mounted share is likely to be present at /run/user/your_UID/gvfs or

/.gvfs in the filesystem.

KDE applications (like Dolphin) has the ability to browse Samba shares built in. Use the path smb://servername/share to browse the files. If you want to access files from on non-KDE application, you can install kio-fuse .

To use a GUI in the KDE System Settings, you will need to install the kdenetwork-filesharing package.

Other graphical environments

There are a number of useful programs, but they may need to have packages created for them. This can be done with the Arch package build system. The good thing about these others is that they do not require a particular environment to be installed to support them, and so they bring along less baggage.

  • pyneighborhoodAUR is available in the official repositories.
  • LinNeighborhood, RUmba, xffm-samba plugin for Xffm are not available in the official repositories or the AUR. As they are not officially (or even unofficially supported), they may be obsolete and may not work at all.

Tips and tricks

Discovering network shares

If nothing is known about other systems on the local network, and automated tools such as smbnetfs are not available, the following methods allow one to manually probe for Samba shares.

1. First, install the nmap and smbclient packages.

2. nmap checks which ports are open:

In this case, a scan on the 192.168.1.* IP address range and port 139 has been performed, resulting in:

The first result is another system; the second happens to be the client from where this scan was performed.

3. Now that systems with port 139 open are revealed, use nmblookup(1) to check for NetBIOS names:

Regardless of the output, look for , which shows the host with open services.

4. Use smbclient to list which services are shared on PUTER. If prompted for a password, pressing enter should still display the list:

Remote control of Windows computer

Samba offers a set of tools for communication with Windows. These can be handy if access to a Windows computer through remote desktop is not an option, as shown by some examples.

Send shutdown command with a comment:

A forced shutdown instead can be invoked by changing -C with comment to a single -f. For a restart, only add -r, followed by a -C or -f.

Stop and start services:

To see all possible net rpc command:

Troubleshooting

Failed to start Samba SMB/CIFS server

  • Check smb.conf on syntactic errors with testparm(1) .
  • Set correct permissions for /var/cache/samba/ and restart smb.service :
Читайте также:  101 ru приложение для windows

Permission issues on SELinux

SELinux not allow samba to access user home directories by default, to solve this, run:

Similarly, samba_export_all_ro and samba_export_all_rw make Samba has the ability to read or «read and write» all files.

Permission issues on AppArmor

If using a share path located outside of a home or usershares directory, whitelist it in /etc/apparmor.d/local/usr.sbin.smbd . E.g.:

No dialect specified on mount

The client is using an unsupported SMB/CIFS version that is required by the server.

Unable to overwrite files, permissions errors

The factual accuracy of this article or section is disputed.

  • Append the mount option nodfs to the /etc/fstab entry.
  • Add msdfs root = no to the [global] section of the server’s /etc/samba/smb.conf .

Windows clients keep asking for password even if Samba shares are created with guest permissions

Set map to guest inside the global section of /etc/samba/smb.conf :

From Samba 4.10.10 you should use Bad Password instead Bad User .

Windows 7 connectivity problems — mount error(12): cannot allocate memory

A known Windows 7 bug that causes «mount error(12): cannot allocate memory» on an otherwise perfect cifs share on the Linux end can be fixed by setting a few registry keys on the Windows box as follows:

  • HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache (set to 1 )
  • HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size (set to 3 )

Alternatively, start Command Prompt in Admin Mode and execute the following:

Do one of the following for the settings to take effect:

  • Restart Windows
  • Restart the Server service via services.msc
  • From the Command Prompt run: ‘net stop lanmanserver’ and ‘net start lanmanserver’ — The server may automatically restart after stopping it.

Windows 10 1709 and up connectivity problems — «Windows cannot access» 0x80004005

This error affects some machines running Windows 10 version 1709 and later. It is not related to SMB1 being disabled in this version but to the fact that Microsoft disabled insecure logons for guests on this version for some, but not others.

To fix, open Group Policy Editor ( gpedit.msc ). Navigate to Computer configuration\administrative templates\network\Lanman Workstation > Enable insecure guest logons and enable it. Alternatively,change the following value in the registry:

Error: Failed to retrieve printer list: NT_STATUS_UNSUCCESSFUL

If you are a home user and using samba purely for file sharing from a server or NAS, you are probably not interested in sharing printers through it. If so, you can prevent this error from occurring by adding the following lines to your /etc/samba/smb.conf :

Restart the samba service, smb.service , and then check your logs:

and the error should now no longer be appearing.

Sharing a folder fails

It means that while you are sharing a folder from Dolphin (file manager) and everything seems ok at first, after restarting Dolphin the share icon is gone from the shared folder, and also some output like this in terminal (Konsole) output:

To fix it, enable usershare as described in #Enable Usershares.

«Browsing» network fails with «Failed to retrieve share list from server»

And you are using a firewall (iptables) because you do not trust your local (school, university, hotel) network. This may be due to the following: When the smbclient is browsing the local network it sends out a broadcast request on udp port 137. The servers on the network then reply to your client but as the source address of this reply is different from the destination address iptables saw when sending the request for the listing out, iptables will not recognize the reply as being «ESTABLISHED» or «RELATED», and hence the packet is dropped. A possible solution is to add:

to your iptables setup.

For Uncomplicated Firewall, you need to add nf_conntrack_netbios_ns to the end of the following line in /etc/default/ufw

and then run the following commands as root:

To make this change persistent across reboots, add the following line at the end of /etc/ufw/sysctl.conf :

Protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE

The client probably does not have access to shares. Make sure clients’ IP address is in hosts allow = line in /etc/samba/smb.conf .

Another problem could be, that the client uses an invalid protocol version. To check this try to connect with the smbclient where you specify the maximum protocol version manually:

If the command was successful then create a configuration file:

Connection to SERVER failed: (Error NT_STATUS_UNSUCCESSFUL)

You are probably passing a wrong server name to smbclient . To find out the server name, run hostnamectl on the server and look at «Transient hostname» line

Connection to SERVER failed: (Error NT_STATUS_CONNECTION_REFUSED)

Make sure that the server has started. The shared directories should exist and be accessible.

Protocol negotiation failed: NT_STATUS_CONNECTION_RESET

Probably the server is configured not to accept protocol SMB1. Add option client max protocol = SMB2 in /etc/samba/smb.conf . Or just pass argument -m SMB2 to smbclient .

Password Error when correct credentials are given (error 1326)

Samba 4.5 has NTLMv1 authentication disabled by default. It is recommend to install the latest available upgrades on clients and deny access for unsupported clients.

If you still need support for very old clients without NTLMv2 support (e.g. Windows XP), it is possible force enable NTLMv1, although this is not recommend for security reasons:

If NTLMv2 clients are unable to authenticate when NTLMv1 has been enabled, create the following file on the client:

This change also affects samba shares mounted with mount.cifs. If after upgrade to Samba 4.5 your mount fails, add the sec=ntlmssp option to your mount command, e.g.

See the mount.cifs(8) man page: ntlmssp — Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message. The default in mainline kernel versions prior to v3.8 was sec=ntlm. In v3.8, the default was changed to sec=ntlmssp.

Mapping reserved Windows characters

Starting with kernel 3.18, the cifs module uses the «mapposix» option by default. When mounting a share using unix extensions and a default Samba configuration, files and directories containing one of the seven reserved Windows characters : \ * ? are listed but cannot be accessed.

Possible solutions are:

  • Use the undocumented nomapposix mount option for cifs
  • Configure Samba to remap mapposix («SFM», Services for Mac) style characters to the correct native ones using fruit
  • Manually remap forbidden characters using catia

The latter approach (using catia or fruit) has the drawback of filtering files with unprintable characters.

Folder shared inside graphical environment is not available to guests

This section presupposes:

  1. Usershares are configured following previous section
  2. A shared folder has been created as a non-root user from GUI
  3. Guests access has been set to shared folder during creation
  4. Samba service has been restarted at least once since last /etc/samba/smb.conf file modification

For clarification purpose only, in the following sub-sections is assumed:

  • Shared folder is located inside user home directory path ( /home/yourUser/Shared )
  • Shared folder name is MySharedFiles
  • Guest access is read-only.
  • Windows users will access shared folder content without login prompt

Verify correct samba configuration

Run the following command from a terminal to test configuration file correctness:

Verify correct shared folder creation

Run the following commands from a terminal:

If everything is fine, you will notice a file named mysharedfiles

Read the file contents using the following command:

The terminal output should display something like this:

Verify folder access by guest

Run the following command from a terminal. If prompted for a password, just press Enter:

If everything is fine, MySharedFiles should be displayed under Sharename column

Run the following command in order to access the shared folder as guest (anonymous login)

If everything is fine samba client prompt will be displayed:

From samba prompt verify guest can list directory contents:

If the NTFS_STATUS_ACCESS_DENIED error is displayed, the issue is likely to be with Unix directory permissions. Ensure that your samba user has access to the folder and all parent folders. You can test this by sudoing to the user and attempting to list the mount directory, and all of its parents.

Mount error: Host is down

This error might be seen when mounting shares of Synology NAS servers. Use the mount option vers=1.0 to solve it.

Software caused connection abort

File managers that utilizes gvfs-smb can show the error Software caused connection abort when writing a file to a share/server. This may be due to the server running SMB/CIFS version 1, which many routers use for USB drive sharing (e.g. Belkin routers). To write to these shares specify the CIFS version with the option vers=1.0 . E.g.:

This can also happen after updating Samba to version 4.11, which deactivates SMB1 as default, and accessing any Samba share. You can reenable it by adding

Connection problem (due to authentification error)

Be sure that you do not leave any space characters before your username in Samba client configuration file as follows:

Источник

Оцените статью