Thursday, 1 December 2016

SAMBA SERVER SETUP

found somewhere on the internet


THIS IS ALSO APPLICABLE ON HOW TO CONFIGURE SAMBA SERVER ON YOUR RASPBERRY PI
TO ACCESS YOUR WINDOWS AND WATCH MOVIES OR ANY MULTIMEDIA STORED IN YOUR SERVER

On centos2, install samba
sudo yum -y install samba samba-client

Backup the file Samba config file located at /etc/samba/smb.conf, and create a new one containing only the following contents (replacing the information as required):
[global]
workgroup = <yourlearnid>.org
server string = "put your real name here without the quotes"
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
hosts allow = 10.40.80. <first three octets of network address followed by period e.g. "192.168.6.">
; note: the above line will allow access from the Seneca domain in lab T2107
  
[home]
comment = "put your real name here without the quotes"
path = /home/<learnid>
valid users = <learnid>
; remember <learnid> is your learnid account name
public = no
writable = yes
printable = no
create mask = 0765
Create a Samba password for your user, by issuing the following command.
sudo smbpasswd -a <learnid>
You can change a user's password if you require by issuing this command (not required).
sudo smbpasswd <username>
Confirm your user's been properly added by issuing the following command:
sudo pdbedit -L -v
Test and review your configuration with the command
sudo testparm
You can now start your Samba server, and enable it to start on boot.
sudo systemctl start smb
sudo systemctl enable smb
Test to see if you have a connection to the samba server.  This command will show you a list of all available shares.
smbclient -U <learnid> -L centos2

Connecting to a Linux SMB Server from a Linux Client

There are many ways that a Linux client can connect to an SMB server.  You can use smbclient, the mount command, a web browser or even graphically through Nautilus.  This next part of the lab will guide you through the steps for each option.
Using SMB Client
You should not have to install samba-client as it should already be present, but if it is not do so.  From centos1, use the smbclient command in a terminal window to connect to your Samba Server.
smbclient '\\centos2\home' -U <learnid>
After entering your password you should see a prompt simliar to the following.
smb: \>
Enter the ls command to see a list of files in your home directory. You may recieve the following error.
smb: \> ls
NT_STATUS_ACCESS_DENIED listing \*
This error is caused by SELinux.  If you've disabled it, you won't see this error.  In order to fix this we need to configure SELinux to allow samba access to home directories.  Issue the following command:
sudo setsebool -P samba_enable_home_dirs 1
Issue the ls command again to confirm the changes have taken effect.  You should see a directory listing.  When you do, close the connection and we'll move on to the next method.
Using 'mount -t cifs'
Install the tools for mounting samba using the mount command.
      yum -y install cifs-utils
The next method we're going to explore to access files on our Samba server is using the mount command.  On centos1, issue the following commands to mount your home directory from centos2.
mkdir /tmp/centos2-home
mount -t cifs //centos2/home /tmp/centos2-home -o username=<learnid>
ls /tmp/centos2-home
Using Nautilus to browse Samba shares
Start a graphical interface on centos1.
Use the "Applications" menu from the desktop and open 'File Browser' under 'System Tools'.
From the menu in the side-bar of the file tool, choose 'Connect to Server...'.
Select 'Custom Location' and enter 'smb://centos2/home' as the location, click 'Connect' and enter your samba password in the prompt.
Where centos2 is the name of the server, and home is the name of the directory it is sharing.
After you have checked that you can access your files, unmount the share by right-clicking its icon in the side-bar and clicking 'Unmount'.
Using a Web Browser to view Samba shares
You can also use a web browser with support for the SMB protocol such as Konqueror.
Note that firefox does not have such support.
If Konqueror is not installed then install it with the command:
sudo yum -y install kdebase
Start Konqueror and enter the following into the address bar
smb://centos2/home
Enter your user name and password when prompted.  When you're done viewing files, close Konquror.
Connecting to a Linux SMB Server from a Windows Client (Windows 7) **** Reference Only, do not perform this part ****
For this next step I've provided you a pre-configured Windows 7 virtual machine.  Download it, copy both files to your backup directory and issue ./vs -r -o win7
The process will take a few minutes, the username and password are ops335/ops335.  When it's been restored, start it up and log in.
Open up Explorer, right click on Computer > Map network drive.. > Select a Drive Letter and '\\<ip-address-of-centos2>\home
You should be prompted for your username and password.  You can now use the browser to drag and drop files to and from the Windows machine.

No comments:

Post a Comment