Samba

Client

Kommandozeile

aptitude -y install smbclient

Alle Samba-Server im Netz zeigen.

mit den Rechten eines bestimmten Benutzers:

# smbtree -U fritz

anonym (klappt aber nicht immer bzw. überall):

# smbtree -N
WORKGROUP
        \\VENUS                         Samba 3.0.23c
                \\VENUS\IPC$            IPC Service (Samba 3.0.23c)
                \\VENUS\HDD1
# smbtree -S -N
WORKGROUP
        \\VENUS                         Samba 3.0.23c

Alle Freigaben auf dem Rechner venus zeigen:

# smbclient -L venus -N
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.23c]
        Sharename       Type      Comment
        ---------       ----      -------
        HDD1            Disk      
        IPC$            IPC       IPC Service (Samba 3.0.23c)
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.23c]
        Server               Comment
        ---------            -------
        VENUS                Samba 3.0.23c
        Workgroup            Master
        ---------            -------
        WORKGROUP            VENUS

Alle Freigaben auf dem Rechner mediabox zeigen:

# smbclient -L mediabox -N
WARNING: The "username" option is deprecated
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.23c]
        Sharename       Type      Comment
        ---------       ----      -------
        HDD1            Disk      
        IPC$            IPC       IPC Service (Samba 3.0.23c)
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.23c]
        Server               Comment
        ---------            -------
        FANTEC               Samba 3.0.23c
        PSD28958             
        Workgroup            Master
        ---------            -------
        WORKGROUP            FANTEC

Alle Freigaben auf dem Rechner venus zeigen, wenn der Netbios-Name und der DNS-Name nicht gleich sind:

# smbclient -L venus -I 192.168.1.1 -N
# smbclient -A /root/.mount -L //venus/

Einloggen in die Freigabe HDD1:

# smbclient //venus/HDD1 -N
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.23c]
Server not using user level security and no password supplied.
smb: \>
smb: \> exit

Als fritz in die Freigabe HDD1 einloggen:

# smbclient //venus/HDD1 -U fritz

Passwortlos in die Freigabe HDD1 einloggen:

# smbclient //venus/HDD1 -A identifikation.txt
# vi /root/identifikation.txt
username = fritz
password = geheim
domain = WORKGROUP

montieren

# aptitude -y install smbfs
# mount //192.168.1.1/HDD1 /mnt/ -t cifs -o guest
# mount //192.168.1.1/HDD1 /mnt/ -t cifs -o cred=/root/identifikation.txt
# mount //192.168.1.1/HDD1 /mnt/ -t cifs -o noperm,iocharset=utf8,rw,file_mode=0775,dir_mode=0775,cred=/root/identifikation.txt //192.168.1.1/HDD1 /mnt/
# mount //192.168.1.1/HDD1 /mnt/ -t cifs -o nobrl,sfu,serverino,noperm,intr,hard,directio,uid=1000,gid=1000,rw,user,cred=/root/identifikation.txt
# mount //venus/HDD1 /mnt/ -o fstype=cifs,ip=192.168.1.1,nobrl,sfu,serverino,noperm,intr,hard,directio,gid=1000,noacl,ro,user,cred=/root/identifikation.txt

Seit Ubuntu-Version 11.04 sollte man die Option „mapchars“ entfernen.

FreeBSD

AutoFS / Automount (Linux)

# aptitude -y install autofs smbfs smbclient
# mkdir -p /etc/autofs/
# vi /etc/autofs/auto.server
venus -fstype=cifs,ip=192.168.1.1,nobrl,sfu,serverino,noperm,intr,hard,directio,gid=1000,noacl,rw,user,cred=/root/identifikation.txt //venus/HDD1
multimedia	-fstype=cifs,ip=192.168.1.2,nobrl,sfu,serverino,noperm,intr,hard,directio,gid=1000,noacl,rw,user,cred=/root/.mount.multimedia	://samba/multimedia
# vi /etc/auto.master
/cifs         /etc/autofs/auto.server -t 6
# /etc/init.d/autofs restart
# ln -s /cifs/venus /home/
# ln -s /cifs/multimedia /home/
# ls -lha /home/venus/
# ls -lha /home/multimedia/

Jetzt wird /venus/HDD1 bzw. /samba/multimedia immer nur bei Bedarf gemountet und nach 6 Sekunden inaktivität, wieder ausgehängt.

Samba-Server

Als erstes muss natürlich Samba installiert werden:

# aptitude -y install samba

Dann brauchen wir einen Systemuser:

# useradd fritz

Samba muss den Benutzer natürlich auch kennen:

# smbpasswd -a fritz

oder für Scripte so:

# echo -e "geheim\ngeheim" | smbpasswd -s -a fritz

Das “-e“ hinter dem echo und das „\n“ zwischen den Passwortwiederholungen sind sehr wichtig, sonst funktioniert das automatische Anlegen des Benutzers nicht!

Jetzt muss Samba (smb.conf) noch konfiguriert werden:

/etc/samba/smb.conf - allgemeines Beispiel

workgroup = ARBEITSGRUPPE
netbios name = SERVERNAME
server string = Samba %v (%h)
security = user
hosts allow = 127. 172.0. 192.168.0.
load printers = no
log file = /var/log/samba/samba.log.%m
socket options = TCP_NODELAY
local master = yes
os level = 64
domain master = yes
preferred master = yes
disable netbios = yes
invalid users = root
strict sync = yes
sync always = yes
kernel oplocks = yes
unix extensions = yes
case sensitive = yes
[Freigabe]
   comment = Bemerkung
   path = /pfad/verzeichnis
   read only = no
   browseable = yes
   public = no
   valid users = fritz fratz

/etc/samba/smb.conf - konkretes Beispiel

[global]
        workgroup        = WORKGROUP
        server string    = Samba Server
        netbios name     = FreeBSD-Server
        wins support     = Yes
        hosts allow      = 192.168.1. 192.168.2. 127.
        log file         = /var/log/%m.log
        max log size     = 50
        security         = share
;       security         = user
;       security         = server
;       force user       = nobody
;       force group      = nogroup
        socket options   = TCP_NODELAY
        os level         = 33
        domain master    = yes
        preferred master = yes
        dns proxy        = no
        client code page = 850
[printers]
        comment          = All Printers
        path             = /var/spool/samba
        browseable       = no
        guest ok         = no
        writeable        = no
        printable        = yes
[tmp]
        comment          = Temporaerer Dateiraum
        path             = /tmp
        read only        = no
        public           = yes
        browseable       = yes
        create mask      = 0777
[homes]
        comment          = Homeverzeichnis
        valid users      = %S
        read only        = No
        browseable       = No
        writeable        = yes
        create mask      = 0700
[var-tmp]
        comment          = allgemeines Dateilager
        path             = /var/tmp
        read only        = No
        public           = yes
        writeable        = yes
        printable        = no
        browseable       = Yes

Glücklicherweise braucht man Samba jetzt nicht neu zu starten!

 
Falls nicht anders bezeichnet, ist der Inhalt dieses Wikis unter der folgenden Lizenz veröffentlicht:GNU Free Documentation License 1.2
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki