Ubuntu – Cannot access shared folder in ubuntu from windows 10

networkingpermissionswindows 10

I have two PCs on my internal LAN. One is running windows 10 and the other is running Ubuntu 16.04. I am trying to share a folder in Ubuntu so that I can access it from windows 10. I have done:

enter image description here

And the clicked "Create Share" which completed without any errors. I also see the shared folder in windows but I need to provide user/password to access it. When I do that, using the same user/password I use to login to Ubuntu, I just get access denied:

enter image description here

Why can't I access that folder using my Ubuntu user credentials?

Best Answer

The way to share folders for other operating systems is a bit different and it needs a little bit of work. Let's go.

  1. sudo apt-get install samba system-config-samba
  2. Create the folder to be shared somewhere outside the /home folder as root.
    For example: sudo mkdir /Public
  3. sudo chmod -R 0777 /Public to make it fully accessible by everyone.
  4. sudo adduser --no-create-home <network_user_name> to create a new user whose name will be used to access the shared folder from the network. Since this user is going to be a network user only, no home folder is needed for them.
  5. sudo usermod -u 998 <network_user_name> to change the new user ID to anything below 1000 so that the name is not included in the lightdm logon list.
  6. sudo smbpasswd -a <network_user_name> to add the new user to the samba user list so that access can be granted when this user attempts to connect from another system.
    Note: This password has nothing to do with the user password you created when you created the user with the adduser command and it doesn't have to be the same. The other password will never be used. This is the password you will be using to access the system from the network.
  7. Run samba from its icon and enter your admin password.
    On the first tab, browse to the /Public folder and select it in order to share it. Make it Visible and Writable if you wish to have write access to it from the network.
    On the second tab make sure to check the network_user_name you'll see so that only that user is granted access to that share and not everyone.
  8. As root, use a text editor and edit /etc/samba/smb.conf. At the end of that file you will see the details about the folder you just shared. Press Enter and Tab and add the parameter inherit permissions = yes at the very end of that shared folder section. This will make sure that every new file or folder created by the network user in that share will inherit the /Public folder's permissions and it'll be fully accessible by all other users.
  9. Finally execute sudo service smbd restart && sudo service nmbd restart to restart both services with the new parameter and you should be ready to use that share from any operating system including Windows.