SDB:Access to Windows Shares

Şuraya atla: kullan, ara


Version: 8.1

Situation

You want to be able to access shared folders on Windows machines from your Linux system.

Manual Procedure

Windows shares can be manually mounted with the command mount. For this purpose, make sure the package samba-client is installed. First, view a share on a Windows machine by executing the following command in a root shell:

smbclient -L netbios-name

netbios-name stands for the NetBIOS name of the Windows machine. If the access attempt fails, an authentication process with the user name is required. In this case, the syntax of the command reads:

smbclient -L netbios-name -U user_name

The output is a list displaying the shares:

earth:~ # smbclient -L winmachine -U testuser
added interface ip=192.168.0.1 bcast=192.168.0.255 nmask=255.255.255.0
Password:
Anonymous login successful
Domain=[WORKGROUP] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
        Sharename      Type      Comment
        ---------      ----      -------
        IPC$           IPC       Remote-IPC
        testshare      Disk      test-share
        ADMIN$         Disk      Remoteadmin
        C$             Disk      Standard share
        Server               Comment
        ---------            -------
        WINMACHINE
        Workgroup            Master
        ---------            -------
        WORKGROUP            WINMACHINE

According to the list, the folder testshare from the computer winmachine is shared. To mount it with the command mount, a mount point must be created:

mkdir -p /windows/winshare

Now mount the Windows share on your file system by means of the following command (replace the computer and folder name with those of your system):

mount -t smbfs //winmachine/testshare /windows/winshare

This command mounts the share testshare of the Windows computer winmachine. The data can be now accessed in the directory /windows/winshare.

If the Windows computer requires an authentication process with the user name, the command's syntax reads:

mount -t smbfs -o username=user,password=secret //winmachine/testshare /windows/winshare

Replace user with the user name needed for the authentication on the Windows machine and secret with the password.

For the folder to be automatically mounted at every system start, insert a corresponding option in the file /etc/fstab (written in a single line):

//winmachine/testshare      /windows/winshare    smbfs
auto,gid=users,fmask=0664,dmask=0775,iocharset=iso8859-15 0 0

The example contains additional options like gid=users, which means that not only root but also common Linux users are allowed to access the Windows share data, or fmask and dmask, which define the permissions with which files or directories will be shown in the local system. iocharset=iso8859-15 determines the character set. View additional options with man smbmount.

Since all the users in the Linux system have read permissions for the file /etc/fstab, the options username and password should not be directly entered here. Instead, use the option credentials=/path/file_name, which enables you to create a file only readable for root in which to store user names and passwords.

The respective line in the file /etc/fstab may look like this (again, everything in a single line):

//winmachine/testshare      /windows/winshare    smbfs
auto,gid=users,umask=0002,iocharset=iso8859-15,credentials=/etc/winpassword 0 0

Then create the password file /etc/winpassword with the content

  username = user
  password = secret

and assign it root-only read and write permissions with the command

chmod 600 /etc/winpassword

Procedure with KDE

The LAN Information Server LISa, available in KDE, provides access to Windows shares very easily by means of the file manager and web browser Konqueror. LISa enables you to search for common resources in your network. Depending on the search method, not only Windows and Samba shares are displayed, but also FTP, HTTP, SSH, and NFS services.

First, make sure that the packages kdenetwork3-lisa, kdenetwork3-lan, kdebase3-samba, samba-client, and (if needed) samba are installed. If not, install them with YaST2.

To setup LISa, start the KDE Control Center and select the following menu items to launch LISa's configuration wizard:

  • Network
  • -> LAN Browsing
  • -> Guided LISa Setup

First, define the search method. The advantages of the method "Send pings" is that, in addition to Windows shares, also computers with other network services are found. Although very reliable, this method is not suitable for large networks.

The package samba must be installed to use the method "Send NetBIOS Broadcasts", because the program nmblookup will be used. Only machines with Windows shares will be found. For additional information, refer to the help texts.

If you have selected the first method, the address range "pinged" by LISa will be defined in the next input field. Enter the network's IP address and netmask. For example, in the case of a private class C network this would be 192.168.0.0/255.255.255.0. You can usually adopt a proposal that is already given. In case of doubt, view the IP and netmask with the shell command:

/sbin/ifconfig

If the LISa service should only be accessed from the Linux computer, enter this machine's IP address and netmask in the input field "Trusted hosts". The IP address of the Linux machine must also be entered in "Own broadcast network address". As for the update interval, simply take the default value 300 sec. The options included in the dialog "Expert settings" are only required if LISa does not find all the computers on the network. Close the configuration.

To save these settings in the file /etc/lisarc on a permanent basis, press the Apply button in the Control Center (lower left corner), enter the root password, and press OK. Now the KDE Control Center can be closed. Then start LISa by entering the following command in a root shell:

rclisa start

For this service to be started automatically during the next boot process, also execute the command

insserv lisa

To access the Windows shares, open KDE's file manager Konqueror and enter lan:/ in the URL field. Those computers providing network services are then listed. Display these services by clicking the host name (smb stands for a Windows share). Then you have access to the resources in that computer.

Further information about LISa is available at http://lisa-home.sourceforge.net.

Problems Accessing LISa

If you obtain the error message "Error while loading 'kio_lan'" when entering lan:/, you are using a faulty update package. In this case, the name of the Windows machine must be entered in Konqueror this way:

smb://netbios-name

Alternatively, reinstall the package kdenetwork3-lan from the CD/DVD.

Note: Mounting Windows shares exceeds the scope of the free-of-charge installation support. The Advanced Support Service is available, however. More information about this service is available under http://www.suse.de/en/services/support/private/advanced.html. <keyword>windows,smb,smbclient,lan,lisa,kdenetwork3,samba-client,share</keyword>