Wiki Ubuntu-it

Indice
Partecipa
FAQ
Wiki Blog
------------------
Ubuntu-it.org
Forum
Chiedi
Chat
Cerca
Planet
  • Pagina non alterabile
  • Informazioni
  • Allegati
  • Differenze per "AlbericoAnobile/Prove0"
Differenze tra le versioni 100 e 101
Versione 100 del 09/10/2007 21.57.02
Dimensione: 2265
Commento:
Versione 101 del 10/10/2007 12.34.45
Dimensione: 4014
Commento:
Le cancellazioni sono segnalate in questo modo. Le aggiunte sono segnalate in questo modo.
Linea 32: Linea 32:
= Montare una directory Samba con autenticazione =

Qualora sia necessario fornire delle credenziali per montare una directory Samba, occorre sostituire il file `/etc/autofs.smb` con il seguente:

[code]
#!/bin/bash
# $Id$
# This file must be executable to work! chmod 755!
key="$1"
# Note: create a cred file for each windows/Samba-Server in your network
# which requires password authentification. The file should contain
# exactly two lines:
# username=user
# password=*****
# Please don't use blank spaces to separate the equal sign from the
# user account name or password.
credfile="/etc/auto.smb.$key"
# Note: Use cifs instead of smbfs:
mountopts="-fstype=cifs"
smbclientopts=""
for P in /bin /sbin /usr/bin /usr/sbin
do
        if [ -x $P/smbclient ]
        then
                SMBCLIENT=$P/smbclient
                break
        fi
done
[ -x $SMBCLIENT ] || exit 1
if [ -e "$credfile" ]
then
        mountopts=$mountopts",credentials=$credfile"
        smbclientopts="-A "$credfile
else
        smbclientopts="-N"
fi
$SMBCLIENT $smbclientopts -gL $key 2>/dev/null \
   | awk -v key="$key" -v opts="$mountopts" -F'|' -- '
        BEGIN { ORS=""; first=1 }
        /Disk/ { if (first) { print opts; first=0 };
             sub(/ /, "\\ ", $2);
        print " \\\n\t /" $2, "://" key "/" $2 }
        END { if (!first) print "\n"; else exit 1 }
[/code]

Il file dovrà avere permessi 755

[code]
sudo chmod 755 /etc/auto.smb
[/code]

Per ogni server a cui si intende accedere, occorre creare un file con nome `/etc/auto.smb.NOMESERVER` contente le credenziali nella seguente forma
[code]
username=user
password=password
[/code]

BR

Introduzione

Autofs monta automaticamente directory condivise quando gli utenti o i processi richiedono accesso ad esse; le smonta automaticamente se restano inattive per un periodo di tempo specificato. Viene utilizzato principalmente per la condivisione di directory accessibili in rete via [:Server/Nfs:Nfs] o [:Server/Samba:Samba]. Il montaggio automatico di dispositivi removibili è infatti già fornito da [http://it.wikipedia.org/wiki/Hardware_abstraction_layer Hal] nel sistema base.

Installazione

Il programma è presente nel [:Repository/Componenti:componente] universe dei [:Repository:repository] ufficiali. Una volta abilitato tale componente è sufficiente [:InstallareProgrammi:installare] il pacchetto autofs.

Configurazione

Modificare il file di configurazione /etc/auto.master aggiungendo le due righe come nell'esempio:

/smb  /etc/auto.smb
/net  /etc/auto.net

Montare una directory Samba pubblica

Supponendo di voler montare una cartelle condivisa con nome condivisionesmb da un server avente nome DNS server.dominio.it, sarà sufficiente portarsi nella directory /smb/server.dominio.it/condivisionesmb.

cd /smb/server.dominio.it/condivisionesmb

Montare una directory Samba con autenticazione

Qualora sia necessario fornire delle credenziali per montare una directory Samba, occorre sostituire il file /etc/autofs.smb con il seguente:

[code] #!/bin/bash # $Id$ # This file must be executable to work! chmod 755! key="$1" # Note: create a cred file for each windows/Samba-Server in your network # which requires password authentification. The file should contain # exactly two lines: # username=user # password=***** # Please don't use blank spaces to separate the equal sign from the # user account name or password. credfile="/etc/auto.smb.$key" # Note: Use cifs instead of smbfs: mountopts="-fstype=cifs" smbclientopts="" for P in /bin /sbin /usr/bin /usr/sbin do

  • if [ -x $P/smbclient ] then
    • SMBCLIENT=$P/smbclient break
    fi

done [ -x $SMBCLIENT ] || exit 1 if [ -e "$credfile" ] then

  • mountopts=$mountopts",credentials=$credfile" smbclientopts="-A "$credfile

else

  • smbclientopts="-N"

fi $SMBCLIENT $smbclientopts -gL $key 2>/dev/null \

  • | awk -v key="$key" -v opts="$mountopts" -F'|' -- '
    • BEGIN { ORS=""; first=1 } /Disk/ { if (first) { print opts; first=0 };
      • sub(/ /, "\\ ", $2);
      print " \\\n\t /" $2, "://" key "/" $2 } END { if (!first) print "\n"; else exit 1 }

[/code]

Il file dovrà avere permessi 755

[code] sudo chmod 755 /etc/auto.smb [/code]

Per ogni server a cui si intende accedere, occorre creare un file con nome /etc/auto.smb.NOMESERVER contente le credenziali nella seguente forma [code] username=user password=password [/code]

Montare una directory Nfs

Supponendo di voler montare una cartella condivisa via nfs con nome condivisionenfs da un server avente nome DNS server.dominio.it sarà sufficiente portarsi nella directory /net/server.dominio.it/condivisionenfs

cd /net/server.dominio.it/condivisionenfs

Immagine(Icone/Piccole/note.png,,center)

Le directory non saranno visibili finchè non si farà esplicito riferimento ad esse, quindi solo dopo l'esecuzione di uno dei precedenti comandi.

Ulteriori risorse


CategoryHomepage