Sunday 16 February 2014

Samba File Server / Install SWAT

I. Server

# yum install samba samba-common samba-client
# yum install xinetd samba-swat

Daemon: /usr/sbin/smbd

Configuration File:  vim /etc/samba/smb.conf

Ports: 445 ------ smbd (tcp) linux service
       137 ------ nmbd (udp) windows servicing


# vim /etc/samba/smb.conf


[global]
workgroup = MYGROUP
server string = Samba Server Version %v

hosts allow = 127. 10.21. 192.168.

log file = /var/log/samba/%m.log

security = user
passdb backend = tdbsam

## Public Share With Read-Wright


[SAM]
comment = SharE DiR
path = /ctechz-samba
# Public is for anonymous user
public = yes
#valid users = jeff manu
writable = yes
browseable = yes
printable = yes
write list = +groupname /
#            @groupname

# service smb restart
# chkconfig smb on

# mkdir /ctechz-samba  ----> Share directory

# If writable = Yes and public access only then give,
# setfacl -m u:nobody:rwx /ctechz-samba

## Check the status of the samba configuration file using testparm

# testparm
Load smb config files from /etc/samba/smb.conf
Processing section "[SAM]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
        workgroup = MYGROUP
        server string = Samba Server Version %v
        passdb backend = tdbsam
        log file = /var/log/samba/%m.log
        hosts allow = 127., 10.21., 192.168.
        cups options = raw


[SAM]
        comment = SharE DiR
        path = /ctechz-samba
        read only = No
        guest ok = Yes
        printable = Yes
           

II. Client side access

# smbclient //10.21.2.110/SAM   -----------> It will ask for password, just press enter to ignore it
Password:
Anonymous login successful
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.33-3.39.el5_8]
smb: \> ls
  .             D        0  Thu Dec 12 17:00:35 2013
  ..            D        0  Thu Dec 12 16:53:38 2013
  apr-0.9.4-24.5.i386.rpm  89620  Thu Dec 12 17:00:35 2013
  j             D        0  Thu Dec 12 17:00:37 2013

       50378 blocks of size 524288. 36841 blocks available

               
[root@localhost ~]# smbclient -N //10.21.2.110/SAM    

-----------> If we add -N it won't ask any password, It will neglect only for public access
Anonymous login successful
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.33-3.39.el5_8]
smb: \> ls
  .          D        0  Thu Dec 12 17:00:35 2013
  ..         D        0  Thu Dec 12 16:53:38 2013
  apr-0.9.4-24.5.i386.rpm  89620  Thu Dec 12 17:00:35 2013
  j          D        0  Thu Dec 12 17:00:37 2013

        50378 blocks of size 524288. 36841 blocks available
smb: \>

III. Configuration with a valid user's

# vim /etc/samba/smb.conf


[global]
workgroup = MYGROUP
server string = Samba Server Version %v

hosts allow = 127. 10.21. 192.168.

log file = /var/log/samba/%m.log

security = user
passdb backend = tdbsam

## Public Share With Read-Wright


[SAM]
comment = SharE DiR
path = /ctechz-samba
valid users = jeff manu
writable = yes
browseable = yes
printable = yes
write list = +groupname /
#            @groupname

# service smb restart
# chkconfig smb on

# mkdir /ctechz-samba

# useradd jeffy
# smbpasswd -a jeffy
New SMB password:
Retype new SMB password:
Added user jeffy.

# smbpasswd -e jeffy   -------> For enabling smb user
Enabled user jeffy.

If it is a valid user,
# chmod 700 /ctechz-samba
# setfacl -m u:jeffy:rwx /ctechz-samba

# service smb restart
# chkconfig smb on

IV. SMB Client for temporary mounting

# smbclient //serverIP/ShareName

# smbclient //serverIP/ShareName -U username 

------> If their is a valid user

# smbclient //10.21.2.110/SAM -U jeffy
Password:
session setup failed: NT_STATUS_LOGON_FAILURE
[root@localhost ~]#
[root@localhost ~]# smbclient //10.21.2.110/SAM -U jeffy
Password:
Domain=[LOCALHOST] OS=[Unix] Server=[Samba 3.0.33-3.39.el5_8]
smb: \> ls
  .             D        0  Thu Dec 12 17:00:35 2013
  ..            D        0  Thu Dec 12 16:53:38 2013
  apr-0.9.4-24.5.i386.rpm 89620  Thu Dec 12 17:00:35 2013
  j             D        0  Thu Dec 12 17:00:37 2013

       50378 blocks of size 524288. 36841 blocks available

If browsing from the client take a web browser and give the URL, Or take it in the file browser first


# smb://ServerIP/ShareName

V. Permenent Mounting

# vim /etc/fstab
//10.21.2.110/SAM  /ctechz-samba  cifs  defaults,username = jeffy, password = jeffy 0 0
# mount -a

# mount.cifs //10.21.2.110/SAM /ctechz-samba -o username=jeffy,password=jeffy
# vim /etc/fstab
//10.21.2.110/SAM  /ctechz-samba  cifs  defaults,credentials=/opt/smbpasswdFile:wq

# mount -a

# vim /opt/smbpasswdFile
username=jeffy
password=jeffy


# chmod 600 /opt/smbpasswdFile

No comments:

Post a Comment