virtual centOS 6.2 - How to share /var/www using Samba - linux

I have Windows XP, installed VirtualBox, and have now a centOS virtual machine.
I am sharing folders between the two machines using Samba.
I have successfully accessed shared folders in the Home directory.
My problem now is how do I access /var/www? (I have exactly the same setting with home directories in smb.conf except path).
Thanks in advance.

You must add such section to the smb.conf:
[www]
comment = Web Root Dir
path = /var/www
valid users = user
public = no
writable = yes
printable = no
User user must exist in the system and in Samba (added by smbpasswd -a user). Of course you can use other username.
Check if your user user can access this filesystem in Linux (without samba). If it can't you must give him access rights in Linux.

Related

Unable to create / edit files as non-root through Samba mount

I'm trying to setup a code-server (vscode in browser) instance and read/write from a mounted samba share. Unfortunately when I try to add a file it gives me an error that I do not have permissions to read/write to that folder. When I try to add files with the same credentials on Windows it does work though. This is the error that VSCode gives me:
Unable to write file
'vscode-remote://localhost:8080/home/user/repository/test'
(NoPermissions (FileSystemError): Error: EACCES: permission denied,
open '/home/gmetitieri/user/test')
If I sudo touch file.txt then the file will be created and added. I already used chmod and added full access to the folder but it still won't work. Is this a credentials thing or am I missing something?
I already tried this answer but it still doesn't let me write as non-root
Edit: This is the command I used to mount the drive (just with different folder names and IP address):
sudo mount -t cifs -o rw,vers=3.0,credentials=/root/.examplecredentials //192.168.18.112/sharedDir /media/share
Considering "non-root through Samba", especially in new releases of OpenSuse (...15.3 -- 15.4), I do few movements into normal configuration panels (no sudo commands or anything technical).
Using Yast Firewall section -- For now (immediate solution):
I turn off the firewall, then see what you can turn on (after this) to keep the samba working with Microsoft Windows.
More details on how to do this with images on my website.
This happens when the directory on the Samba share does not have permission for non-root users.
In your smb4.conf file:
[test]
comment = Test share
path = /path/to/directory
force user = unixuser
valid users = sambauser
In this example, unixuser should be the owner of the files in /path/to/directory. The user logged into Samba in this example is a user called sambauser.

Vsfp user don't see any data linux Rhel/Centos

I tried creating vsftp server on Rhel 8 and centos. My ftp Users can login into server but only sed list of directory's and are able to navigate to any directory.
User cannot create directory or file
User cannot see any files in any directory.
I chnage chmod 777
And changed ownership but nothing works
It was selinux config I had to change under /etc/selinux/config
changed enforcing to disable

Vagrant shared folder without sync

How can I have a shared folder (access to the same folder from both host and guest machines) WITHOUT any syncing method running? (I want to use my own rsync script which is exactly what I need without the Vagrant file sharing performance penalties).
I have tried
config.vm.synced_folder ".", "/vagrant", disabled: true
but it disables the entire share.
I'm using Vagrant 1.8.1 on Windows 7 (host) with Virtualbox 5.0.12 and guest OS is Ubuntu 12.04.
You can indeed share a folder simply using the VirtualBox Manager.
Disable the Vagrant synced folder (in the vagrantfile):
config.vm.synced_folder ".", "/vagrant", disabled: true
Install Guest Additions to VirtualBox
Open VirtualBox Manager and select Settings > Shared Folders > Adds new shared folder (sic)
Add your host path in "Folder Path:" and your guest name (eg FolderName) in "Folder Name:"
Your guest name will appear in the guest linux in /media/sf_FolderName
Give your preferred guest user access to the folder. I did sudo adduser vagrant vboxsf and sudo chmod 777 /media/sf_FolderName and it DID NOT WORK for me - vagrant user still gets permission denied. Those commands seem to have worked for others, but I have ended up just working as root, which does have access.
Incidentally, here's my rsync formula (with a watch that polls every second) which works really well for me.
sudo watch -n 1 rsync -avh --delete --exclude-from=/media/sf_FolderName/FOLDERTOCOPY/rsync-exclude.txt /media/sf_FolderName/FOLDERTOCOPY /path/to/destination
NOTE: It works only if you're making changes on the host (eg developing using editor in Windows in my case). If you're making changes on the guest (eg git pull) you're gonna wanna stop this the watch/rsync from running and manually copy back in the other direction. Not ideal, but at least developing with this setup is fast.
Thanks to Frederic Henri for nudging me in this direction.

Remotely Changing permissions of file pushed to W7 machine using smbclient

I have a file that I want to transfer to a remote machine that is running W7 32 bit
I have a script that enables me to push the file to the machine from a linux management server, using a combination of:
1) smbclient to mount the Admin share on the W7 machine
2) winexe to move the file to the location I require
This leaves me with the file in the correct location, but owned by the Admin user - whereas I need it to be editable by a standard user, User1
I have been trying to resolve this by using icacls
Using winexe I can run this remotely on the W7 machine. Initially I tried setting the poermissions to "Full" for the user account:
icacls c:......\myFile /grant User1:F
Checking this from the command line showed that it had apparently worked:
icacls c:......\myFile
c:......\myFile User1:(F)
However, from the windoes desktop, the file properties dialogue showed User1 having only read permissions, and anything else gave access denied.
My next attempt was:
icacls c:......\myFile /setowner User1
However, when logged in to the windows desktop as User1, attempting to delete or edit the file now tells me that doing so requires permission from User1....which is a bit peverse, since I am logged in as User1....
Any ideas?
This may or may not help, but I was unable to delete a file I copied from a Linux machine to a Windows shared folder - was getting a 'need Administrator permission' type error.
I was trying to solve this with the smbclient -c "setmode -r;" option, but when this didn't work I realised the Windows folder itself was set for read-only access for all but Administrator level.

Samba able to copy folders but unable to copy files

I am currently using CentOS 6.5 and trying to share files over a samba share. On the other machine is Windows 8 x64. I am able to transfer folders from Windows to CentOS over without issues but however, when I try to copy a single file over to CentOS, I get permission denied error on Windows.
Permissions of the folder is as follows:
drwxrwxrwx. 5 user01 smbusers 4096 Feb 28 23:23 srv
And the smb.conf:
[srv]
comment = Data
path = /srv
browseable = yes
writable = yes
read only = no
valid users = #smbusers
workgroup = WORKGROUP
create mask = 0775
directory mask = 0775
I would like to know what is the problems that is preventing me from copying files over but not folders. Contents inside the folders get copied over without issues. Help appreciated. Thanks in advance!
Try to change the owner of directory/folder where you are going to copy the file in CentOS from Windows, it's usually done by chown command. For example if you want to the change the owner of directory named share from root to your_user_name, you can do this by following command,
sudo chown your_user_name share
This will change the owner of share folder to your login user.

Resources