How I Enabled Sharing of a directory via Samba in Nautilus
Posted: Thu Feb 10, 2011 1:00 am
This brief how to should assist a user with enabling sharing of a directory in that users home using the right click menu, properties, and share. As with anything, this worked for me but may not work for you. There is also probably a more secure way of doing what you want, but in a home setting, on a desktop, where you trust the people in your network it works fine for me. It will be up to the individual user to decide whether it will work in their specific situation.
In Ubuntu this worked out of the box, in LMDE I received an error upon clicking "Create Share" that went something like this.
Searching for this error gave multiple hits. The first clue for me was the permission denied error. Someone, somewhere, suggested running Nautilus as root but this didn't seem the right way to go so I hazarded a guess that my user might not have the correct permissions to perform this function.
First, I checked to make sure I actually had the directory mentioned.
should bring you to the root shell. to make sure it's there. I was not able to do this as a normal user because of permissions issues, hence the need to become root. To drop back down
In this bug report: https://answers.launchpad.net/ubuntu/+s ... tion/31818 in the last post (September 2010) a user suggested: This did not work for me
Since I was trying this as a user I edited it, and in place of root I put my username so that it read Replace my username with yours, obviously!
If I understand correctly this sets you as the owner and sambashare as the group of /var/lib/samba/usershare
This needed to be run with root privileges so it might be necessary to add a 'sudo' in front of it for you as it was for me.
Following this step I was able to successfully create the share and view it on my Windows box, however, I was not able to get in as it said I had the wrong password.
To fix this I used 'smbpasswd'. From their man page:
Again replace my name with your own user name.
Enter your new password twice and you should be all set!
Notes, please read.
Following this I was successfully able to browse my home directory, not just the "Public" directory as I originally requested. I'm unsure of why it didn't. Perhaps (and this is only a guess) Samba had shared my home directory by default and changing the password as we just did above allowed me to access it. The first part of this guide, chowning /var/lib/samba/usershares, may actually be completely unnecessary if you can view your machine in network locations but just cannot access it. As I said though, for me this works perfectly.
I hope this helps someone setup sharing quickly and easily. Tips, suggestions on how to make this more secure or better are of course welcome. I'm no master here by any means, however, this got me up and sharing without breaking anything so I deem it a success!
In Ubuntu this worked out of the box, in LMDE I received an error upon clicking "Create Share" that went something like this.
Code: Select all
'net usershare' returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied
You do not have permission to create a usershare. Ask your administrator to grant you permissions to create a share.
First, I checked to make sure I actually had the directory mentioned.
Code: Select all
sudo su
Code: Select all
cd /var/lib/samba/usershares/
Code: Select all
exit
Code: Select all
chown root:sambashare on the /var/lib/samba/usershare
Since I was trying this as a user I edited it, and in place of root I put my username so that it read
Code: Select all
sudo chown dave:sambashare var/lib/samba/usershare
If I understand correctly this sets you as the owner and sambashare as the group of /var/lib/samba/usershare
This needed to be run with root privileges so it might be necessary to add a 'sudo' in front of it for you as it was for me.
Following this step I was able to successfully create the share and view it on my Windows box, however, I was not able to get in as it said I had the wrong password.
To fix this I used 'smbpasswd'. From their man page:
Running plain old smbpasswd in terminal asks you for your Old password which, of course, I did not know. Run with the -a switch smbpasswd adds the username to the local smbpasswd file. If the user already exists in that file then the command is treated as a regular request to change the password. Note: this requires sudo in front of it, as I have done, or else it will fail as noted in the man pages.The smbpasswd program has several different functions, depending on
whether it is run by the root user or not. When run as a normal user it
allows the user to change the password used for their SMB sessions on
any machines that store SMB passwords.
Code: Select all
sudo smbpasswd -a dave
Enter your new password twice and you should be all set!
Notes, please read.
Following this I was successfully able to browse my home directory, not just the "Public" directory as I originally requested. I'm unsure of why it didn't. Perhaps (and this is only a guess) Samba had shared my home directory by default and changing the password as we just did above allowed me to access it. The first part of this guide, chowning /var/lib/samba/usershares, may actually be completely unnecessary if you can view your machine in network locations but just cannot access it. As I said though, for me this works perfectly.
I hope this helps someone setup sharing quickly and easily. Tips, suggestions on how to make this more secure or better are of course welcome. I'm no master here by any means, however, this got me up and sharing without breaking anything so I deem it a success!