Samba: Difference between revisions
No edit summary |
No edit summary |
||
Line 47: | Line 47: | ||
* [https://www.cyberciti.biz/faq/what-ports-need-to-be-open-for-samba-to-communicate-with-other-windowslinux-systems/ What Ports Need To Be Open For Samba To Communicate With Other Windows/Linux Systems?] Ans: 139 & 445. | * [https://www.cyberciti.biz/faq/what-ports-need-to-be-open-for-samba-to-communicate-with-other-windowslinux-systems/ What Ports Need To Be Open For Samba To Communicate With Other Windows/Linux Systems?] Ans: 139 & 445. | ||
** [https://www.varonis.com/blog/smb-port/ What is an SMB Port + Ports 445 and 139 Explained] | ** [https://www.varonis.com/blog/smb-port/ What is an SMB Port + Ports 445 and 139 Explained] | ||
* [http://www.noobslab.com/2012/03/configure-samba-sharing-between-ubuntu.html Share 'between' ubuntu and Windows] | * [http://www.noobslab.com/2012/03/configure-samba-sharing-between-ubuntu.html Share 'between' ubuntu and Windows] | ||
* [http://www.linuceum.com/Server/srvSambaDaemons.php Start and stop the samba daemons] | * [http://www.linuceum.com/Server/srvSambaDaemons.php Start and stop the samba daemons] | ||
Line 116: | Line 115: | ||
== Share printer == | == Share printer == | ||
[https://www.makeuseof.com/tag/make-wireless-printer-raspberry-pi/ How to Make Your Own Wireless Printer With a Raspberry Pi] | [https://www.makeuseof.com/tag/make-wireless-printer-raspberry-pi/ How to Make Your Own Wireless Printer With a Raspberry Pi] | ||
== create mask, directory mask == | |||
* [http://www.bodenzord.com/archives/53 Understanding UMASK with Linux and Samba] | |||
* [https://docs.fedoraproject.org/en-US/quick-docs/samba/ How to create a Samba share] | |||
** create mask = 0660: files in the share are created with permissions to allow all group users to read and write files created by other users. | |||
** directory mask = 0770: as before, but for directories. | |||
= Remove and re-install Samba = | = Remove and re-install Samba = |
Revision as of 16:05, 20 February 2023
Samba - allows Linux to transfer files with Windows clients
- http://www.krizna.com/ubuntu/setup-file-server-ubuntu-14-04-samba/ (Anonymous share and Secured share via username/password)
- Samba can use the system user name but it doesn't use the system account password. That is, we need to set up a Samba password for our user account
- It is fine to use an existing directory to share
- How to Set Up a Network Shared Folder on Ubuntu With Samba 2021
- https://www.howtoforge.com/tutorial/samba-server-ubuntu-16-04/
sudo apt-get install -y samba samba-common python-glade2 system-config-samba sudo cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak sudo sh -c 'cat /dev/null > /etc/samba/smb.conf' sudo nano /etc/samba/smb.conf sudo service smbd restart testparm # password protected sudo addgroup smbgrp sudo useradd till -G smbgrp sudo smbpasswd -a SOMEEXISTEDUSER sudo mkdir -p /samba/secured cd /samba sudo chmod -R 0770 secured sudo chown root:smbgrp secured sudo nano /etc/samba/smb.conf sudo service smbd restart testparm sudo netstat -pant | grep smbd # mine shows 139 & 445
- I have trouble to connect to the samba server though connecting it itself from the samba server works fine.
$ smbclient -L //192.168.1.XX/sambashare -U SOMEEXISTEDUSER WARNING: The "syslog" option is deprecated Connection to 192.168.1.XX failed (Error NT_STATUS_IO_TIMEOUT) # From server itself $ smbclient -L //localhost # Solution: ufw # https://askubuntu.com/a/184806 sudo ufw allow Samba # From the client $ smbclient -L //192.168.1.XX/sambashare -U YYY # No error. Return to the local prompt again. # Now we can use Ubuntu's Files app to connect to the server # smb://192.168.1.XX/
- What Ports Need To Be Open For Samba To Communicate With Other Windows/Linux Systems? Ans: 139 & 445.
- Share 'between' ubuntu and Windows
- Start and stop the samba daemons
$ ps -ef | grep smbd # see if the Samba daemon (smbd) $ ps -ef | grep nmbd # see if the NetBIOS name server daemon (nmbd) is running $ sudo service smbd stop # does not stop nmbd $ sudo service nmbd stop $ sudo service smbd start $ sudo service nmbd start
sudo apt-get install samba samba-common sudo apt-get install python-glade2 sudo apt-get install system-config-samba
Use Dash and search for 'samba'. It will ask for the user's password first. The samba password can also be set by
sudo smbpasswd -a USERNAME
A non-gui way to configuration samba is adding the following to the end of /etc/samba/smb.conf file, sudo nano -w /etc/samba/smb.conf (-w means no-wrap). Any line beginning with a semicolon (“;”) or a hash (“#”) character is ignored.
[brb] path = /home/brb ; writeable = no ; browseable = yes guest ok = yes
- Share between ubuntu and linux On the client file manager, type smb://192.168.1.XX/
- https://help.ubuntu.com/community/Samba
- (2020-04-27) Ubuntu 18.04. (2022-03) Ubuntu 20.04. This is following the class "Building an Ubuntu Home Server" in lynda.com
- mkdir /mnt/stored/shared
- chmod 444 /mnt/storage/shared # optional
- sudo apt install samba
- sudo nano /etc/samba/smb.conf. Scroll down to the bottom and add
- testparm
- sudo systemctl restart smbd
- sudo smbpasswd -a CurrUserName (required)
- sudo useradd user2 # optional
- sudo passwd user2 # optional
- sudo smbpasswd -a user2 # optional
- sudo ufw allow 139/tcp # depends
- sudo ufw allow 445/tcp # depends
[fileshare] comment = share files path = /mnt/storage/shared readonly = yes create mask = 0444 directory mask = 0444
On Windows PC, go to start and open 'Run' then enter ip with double backslash. Like this (\\192.168.1.XX). On macOS/Linux, "Connect to Server" in the file browser, smb://192.168.1.XX/fileshare.
On Android, FE explorer, click "+". Enter Display Name, Host Name IP, Path, Port 445, User Name/PW. Save. It works.
Raspberry pi
Build your own NAS drive with Raspberry Pi
How to Make Your Own Wireless Printer With a Raspberry Pi
create mask, directory mask
- Understanding UMASK with Linux and Samba
- How to create a Samba share
- create mask = 0660: files in the share are created with permissions to allow all group users to read and write files created by other users.
- directory mask = 0770: as before, but for directories.
Remove and re-install Samba
$ sudo apt-get remove --purge samba $ sudo apt-get remove --purge smbclient libsmbclient $ sudo apt-get install samba $ sudo apt-get install smbclient libsmbclient
SambaCry vulnerability and check Samba version
To check your samba version
$ smbd -V Version 4.3.11-Ubuntu
sudo mount -t cifs \ -o username=YOURUSERNAME,password=YOUPASSWORD \ //server_name_or_ip/folder_to_mount \ /mnt/folder_to_mount_to/
Permission denied on soft-link folders
(Works on Ubuntu 22.04) How do you make samba follow symlink outside the shared path
[global] allow insecure wide links = yes [share] follow symlinks = yes wide links = yes
sudo service smbd restart
Example of /etc/samba/smb.conf
[global] workgroup = WORKGROUP server string = Samba Server %v netbios name = ubuntu security = user map to guest = bad user dns proxy = no logging = syslog@0 file allow insecure wide links = yes [share] comment = share files path = /home/XXX/Path1 readonly = yes # create mask = 0444 # directory mask = 0444 follow symlinks = yes wide links = yes [taichiVideo] comment = tai chi video path = /Path2/ read only = yes writable = no browsable = yes guest ok = yes