File sharing between Windows and CentOS8 through Samba

Issues related to applications and software problems and general support
Post Reply
tyler.r
Posts: 4
Joined: 2021/04/09 14:55:31

File sharing between Windows and CentOS8 through Samba

Post by tyler.r » 2021/04/09 15:07:09

Hello, I am trying to set up file sharing between my windows domain and centOS8 using samba and am having a few difficulties. This is only my first week using centOS so I am still very new to this.
I am using a VM for this. Hostname for CentOS is trj and it was successfully joined to the domain(computer account created in ADUC). I also enabled SMB in windows programs/features. My share that I created is named myshare in /mnt.
I started running into issues when:
cannot mount
cannot mount
mount.PNG (51.7 KiB) Viewed 1057 times
(I originally did username=user)
/myshare not listed
/myshare not listed
shares.PNG (95.32 KiB) Viewed 1057 times
workgroup SMB1 disabled
workgroup SMB1 disabled
workgroup.PNG (62.49 KiB) Viewed 1057 times
I will also post my two files i've edited. What it boils down to, is I cannot connect to the centos VM from my windows environment. It is pingable but I cannot access the share through file explorer. If anyone can tell me if I'm missing something or help point me in the right direction, it would be appreciated!
Last edited by tyler.r on 2021/04/09 15:27:43, edited 1 time in total.

tyler.r
Posts: 4
Joined: 2021/04/09 14:55:31

Re: File sharing between Windows and CentOS8 through Samba

Post by tyler.r » 2021/04/09 15:13:07

Here are the /etc/fstab and /etc/samba/smb.conf files i've edited.
fstab.PNG
fstab.PNG (232.45 KiB) Viewed 1048 times
smb.conf
smb.conf
.conf.PNG (116.74 KiB) Viewed 1055 times
Just in case too, heres my directory that's trying to be shared under /mnt
ls mnt.PNG
ls mnt.PNG (21.87 KiB) Viewed 1055 times
Last edited by tyler.r on 2021/04/09 15:26:42, edited 1 time in total.

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: File sharing between Windows and CentOS8 through Samba

Post by TrevorH » 2021/04/09 15:21:50

Not a wise idea to post passwords in plain text even if part of an image. I removed it.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

tyler.r
Posts: 4
Joined: 2021/04/09 14:55:31

Re: File sharing between Windows and CentOS8 through Samba

Post by tyler.r » 2021/04/09 15:25:06

TrevorH wrote:
2021/04/09 15:21:50
Not a wise idea to post passwords in plain text even if part of an image. I removed it.
big whoops... thank you.. I updated it with it blocked out.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: File sharing between Windows and CentOS8 through Samba

Post by jlehtone » 2021/04/09 15:35:35

First, it would be nice if you could copy-paste text from VM rather than screenshot.

You mount with -o username=root but smbclient -U user. Should you use the same account for both?
(Furthermore, your account is 'trj', yet another identity.)

The 'myshare' shares path /share. What is in there? ls -la /share

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: File sharing between Windows and CentOS8 through Samba

Post by TrevorH » 2021/04/09 16:17:56

Ah, yes, non-standard paths like /share will need selinux action to be taken. Read /etc/samba/smb.conf.example for how to do so.

Some configurations of samba also require you to use the smbpasswd command to set up the user in question. In any case, it's not wise to attempt to use root for it.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: File sharing between Windows and CentOS8 through Samba

Post by MartinR » 2021/04/09 16:45:10

A slightly off the wall thought, do you need Samba, or would running your own cloud achieve the same result? I run OwnCloud (though NextCloud has plenty of supporters, YMMV) hosted on a C8 machine. It's accessible from Win10, Win7, Fedora, Alma, Springdale, C7 and Raspian.

tyler.r
Posts: 4
Joined: 2021/04/09 14:55:31

Re: File sharing between Windows and CentOS8 through Samba

Post by tyler.r » 2021/04/09 19:47:20

My apologies, I haven't posted on forums very much. I will look into selinux for the smb.conf & avoid using root(I did a -o username=user first). I don't know if anything else is needed, but I did a
semanage fcontext -a -t samba_share_t "/share(/.*)?"
restorecon -R -v /share
And then started and enabling smb/nmb with systemctl.
I already set smbpasswd -a user, This is purely a testing environment, no need to actually implement it, I am just trying to learn! What's located in /share is just a test file right now.
total 0
drwxrwxrwx. 3 root root 18 Apr 9 08:32 .
dr-xr-xr-x. 18 root root 237 Apr 9 08:01 ..
drwxr-xr-x. 2 user user 6 Apr 9 08:32 test

jscarville
Posts: 135
Joined: 2014/06/17 21:50:37

Re: File sharing between Windows and CentOS8 through Samba

Post by jscarville » 2021/04/14 19:22:00

I have to mount windows shares on Linux servers quite a bit here. This is a procedure I have worked out.

Define a remote machine and a share name

Code: Select all

export MACHINE="abc.def.xyz"
export SHARE="fooshare"
Create a mountpoint

Code: Select all

sudo mkdir -p /smbfs/$MACHINE/$SHARE
Create a directory to store credential files in

Code: Select all

sudo mkdir -p -m 0700 /etc/.credentials/$MACHINE
Create a credential file. I name it /etc/.credentials/$MACHINE/$SHARE. The credential file has two or three lines. The domain entry is usually optional.

Code: Select all

  username=<user>
  password=<password>
  domain=<domain>
Set the permissions on the credential file

Code: Select all

sudo chmod 0600 /etc/.credentials/$MACHINE/$SHARE
Test with mount

Code: Select all

sudo mount -t cifs //$MACHINE/$SHARE /smbfs/$MACHINE/$SHARE -o credentials=/etc/.credentials/$MACHINE/$SHARE
Test with smbclient

Code: Select all

sudo smbclient //$MACHINE/$SHARE -A /etc/.credentials/$MACHINE/$SHARE
Add to fstab (make appropiate substitutions)

Code: Select all

//$MACHINE/$SHARE /smbfs/$MACHINE/$SHARE cifs credentials=/etc/.credentials/$MACHINE/$SHARE,defaults,users,auto,uid=oracle,gid=dba 0 0
Mount

Code: Select all

sudo mount -a

Post Reply