1. installation of related components # apt-getinstallopenssh-client ----------------------- install the ssh service # apt-getinstallsambasamba-common ----------------------- install the samba Server # apt-getinstallsmbclien
1. installation of related components
# Apt-get install openssh-client <------------------------- install the ssh service
# Apt-get install samba-common <------------------------- install the samba Server
# Apt-get install smbclient smbfs <------------------------- install the samba client
2. enable/disable/restart the samba service
Debian :~ #/Etc/init. d/sambastart/stop/restart <---------------- start the samba service again
To disable the Samba server, you can also use the following methods, which are mostly common. you need the root permission to execute them;
Debian:/home/weimen # pkill smbd
Debian:/home/weimen # pkill nmbd
Debian:/home/weimen # pgrep smbd <---------------- check whether smbd and nmbd work
7931
7934
Debian:/home/weimen # pgrep nmbd
7929
Query the samba working Port:
Debian:/home/weimen # netstat-tlnp | grep smb
Tcp6 0 0: 139: * LISTEN 7931/smbd
Tcp6 0 0: 445: * LISTEN 7931/smbd
3. samba configuration
3.1 check the current configuration
Our samba is now running. What services does it provide? We can use testparm. This command allows us to check whether the configuration of smb. conf is correct, and can also list a valid smb. conf content:
# Testparm
Through this command, we can see that the configuration that actually plays a role is just a few lines.
3.2 Use the smbpasswd command to add samba users:
Debian:/home # smbpasswd-a root <---------------- the user name must be existing in the system, such as root. you can press enter without a password.
Note: delete the user using the command smbpasswd-x fantity
New SMB password:
Retype new SMB password:
Added user root.
# Smbpasswd-a test
New SMB password:
Retype new SMB password:
Failed to add entry for user test.
Solution:
The error "Failed to add entry foruser" is prompted because the corresponding system account is not added. you only need to add the corresponding system account "test:
# Pw groupadd test-g 6000
# Pw useradd test-u 6000-g 6000-s/sbin/nologin-d/dev/null
Now you can use smbpasswd-atest to add the samba account "test! To increase system security, do not assign shell or directory to the added system account. in the/home directory, create a folder for the test account, only test has the read and write permissions for this folder! For example:
# Mkdir/home/test
# Chown-R test: test/home/test
If you do not want another user to access the database, you only need to execute the following command:
# Chmod u + rwx, g + rwx, o-rwx/home/test
In this case, you can use the smbpasswd command to add the samba account test.
# Smbpasswd-a test
New SMB password:
Retype new SMB password:
Added user test.
3.3 enter \ 192.168.206.129 <---------------- as the IP address of the virtual machine in a windows browser or running
You can access the shared directory in Linux.
3.4/etc/samba/smb. conf file content
Debian:/home # cp/etc/samba/smb. conf/etc/samba/smb. conf. bak <---------------- back up the original configuration file
Debian:/home # vim/etc/samba/smb. conf <---------------- re-create smb. conf
Add the following content to the simplest sharing:
[Global]
Log file =/var/log/samba/log. % m
Wins support = no [share]
Comment = shared file space
Path =/home/share
Browsable = yes
Writable = yes
Valid users = fantity
3.5 View shared files in Linux
Debian:/home # smbclient-L // 192.168.206.129
Enter root's password:
Domain = [DEBIAN] OS = [Unix] Server = [Samba 3.2.5]
Sharename Type Comment
--------------------
Share Disk Temporary file space
IPC $ IPC Service (Samba3.2.5)
Domain = [DEBIAN] OS = [Unix] Server = [Samba 3.2.5]
Server Comment
----------------
Workgroup Master
----------------
WORKGROUP DEBIAN
Debian:/home # smbtree <---------------- display the tree of the shared directory
Password:
WORKGROUP
\ WWW-B12606289FA
Cli_rpc_pipe_open: cli_nt_create failed on pipe \ srvsvc to machineWWW-B12606289FA. Error was NT_STATUS_ACCESS_DENIED
\ DEBIAN Samba 3.2.5
\ DEBIAN \ IPC $ IPC Service (Samba 3.2.5)
\ DEBIAN \ share Temporary file space
Debian:/home # findsmb <---------------- search for machines with shared services in this segment
* = DMB
+ = LMB
Ip addr netbiosname workgroup/OS/VERSION
---------------------------------------------------------------------
192.168.206.1 WWW-B12606289FA [WORKGROUP] [Windows 5.1] [Windows 2000 LAN Manager]
192.168.206.129 DEBIAN + [DEBIAN] [Unix] [Samba 3.2.5]