So, we're going to take a look at getting a little bit Window‑y at the moment.
Working on our AlmaLinux system, we can go through and install our Samba server.
We can go through and make sure that we edit the existing
smb.conf and sharing out our data directory.
We can go through and start the SMB service,
and with the SMB service running,
we can make sure that we create a user account for our vagrant user.
We need a user that both exists in Linux,
as well as in the Samba database system.
With that done,
the final thing that we need to do is make sure that SELinux is playing nicely.
So we can go through and set the SELinux context of the data directory,
as well as all of its contents,
so that it's available for use with our Samba server.
Now when we're looking at connecting from our Ubuntu client,
we can make sure that the mount directory is not currently mounted.
We can make sure that we update our metadata for the apt cache,
and then go ahead and install our cifs‑utils package.
It's this package that has the correct protocols to
connect to the remote Windows file system.
We can then go ahead and mount, including our options,
for the username and password.
We don't want to put the password into the command line.
We can be prompted for the password if it's not included,
or we can create a credentials file,
having the username and password in our credentials file.
But this is then going to allow us to connect to the data share
and mount it through to our /mnt directory.
So I think we need to go through and take a look working with our,
say, the Alma system as our Samba server,
the Ubuntu system as our client.
We can then go through, create the shares on Alma,
create our Samba user, and connect from Ubuntu.
And here we are on our AlmaLinux 8.5 system.
You can see I'm working as root, so I don't need to worry about sudo,
and I can go straight ahead and install our Samba server.
And that's done by adding in both the samba package
and the samba‑common package.
There'll be other dependencies that are added in,
but we can allow then the process to run through.
And, of course, once it has installed,
we're going to go through and edit the Samba configuration file,
the smb.conf.
So I'm going to use then my editor vim.
Use whichever editor you're happy with,
but moving through into the /etc and Samba and smb.conf.
Now we can leave most things at the default.
So I'm just going to move to the end of the file and then insert a new share.
We want to share out our data directory.
So I can go through and add in then our data directory.
The share name goes in the square brackets.
And the reality is that if I can accept most of the defaults,
I just need to add in the path key, so we know what we are sharing out.
So for me, it's going to be the data directory.
You can always investigate the manned page for the smb.conf if you
want to see more options that are available.
Now when I take a look inside of the data directory,
I can see then that I've got a couple of pages,
and when we look at the permissions of the directory,
we can see that it's readable and executable by others.
So we're not so worried about the user account in Linux,
it could be any of our user accounts,
they're all going to have at least read and execute through to this directory.
But we do need to make sure that we have both a
Linux account and a Samba account.
We can edit our Samba users with the pdbedit command,
‑a adds a user, and we're adding in the vagrant user.
The vagrant user has to exist in both Linux and Samba.
And, of course, we can then add in our password,
and this password is then unique to this user.
Of course, we've got to get the passwords correct,
so let's just run through this again.
So ideally, the password is not the same as the Linux password,
so it's not going to compromise any of our security in Linux,
or the Linux password is not going to compromise any of our
security on the Windows side of things.
Now that we've got a user we can connect to as,
we can go ahead and start our Samba service,
and that's just smb.
So with that up and running, we're almost done.
But if I go through and take a look at the SELinux
context of our data directory,
this is then where we have SELinux enabled by default,
it's going to cause us problems.
The default_type is not going to play nicely with the Samba server.
So we're going to use the command chcon to change the SELinux context.
The type we're setting through to samba_share_t for type,
and we can recursively set it on the data directory and everything below.
V would just give us a printout, such as we're seeing here,
saying the security context has changed.
We can go through and double‑check this,
again, by using the ls command with the option ‑Z.
We can go through and look at the security context
of our files in our file system.
We can see that it's set correctly.
It's now samba_share_t.
So we're just about ready to go as far as this system is concerned.
So moving across now to Ubuntu, we can go through and update our package cache,
so sudo and apt update,
before going through and running our apt install ‑y and cifs‑utills.
So this is going to put on the protocols that we need
to be able to connect to our share.
Now that they're available, I can clear my screen,
so CTRL + L, I'm going to make sure that the mount directory,
/mnt, is not currently mounted.
We had previously mounted it for NFS, but it looks like we're good to go.
So we can go back into sudo, but this time mount ‑o for options,
and we're going to put user=vagrant,password=,
and then whatever password you used for your Samba vagrant user,
and then put in //192.168.33.11, or whatever your IP address is,
/data, and we can mount it through to the mount directory.
Listing our mount directory, of course, now it's displaying the shared content.
So there you go.
We've been able to set our base Samba server and connect to it using the CIFS client.