Difference between revisions of "Installing Samba from the command line"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
(Created page with "Basic Samba install & minimal configuration Create a test folder & file to be shared. (Assuming you'll replace '''USER''' with your own username...) * mkdir ~'''USER'''/share * touch ~'''USER'''/share/Foo Install Samba * sudo apt install samba -y Configure the test share * sudo vi /etc/samba/smb.conf [New_share] comment= my share path = /home/'''USER'''/share browseable = yes Read only = no guest ok = no valid users = '''USER''' * sudo s...")
 
 
(33 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{{!}} class="wikitable" style="float: right; width: 322px;" border="2"
{{!}}+ Proven on:
{{!}}- --="" debian=""
{{!}} style="text-align: center; width: 60px;" {{!}} [[File:Logo Debian.png{{!}}60px{{!}}link=https://www.debian.org/{{!}}center{{!}}middle{{!}}frameless]]
{{!}} style="text-align: center; width: 40px;" {{!}} 11 (bullseye)
{{!}}
<br>
{{!}}}
Basic Samba install & minimal configuration
Basic Samba install & minimal configuration


Create a test folder & file to be shared. (Assuming you'll replace '''USER''' with your own username...)
= Create a test folder & file to be shared. =
* mkdir ~'''USER'''/share
(Assuming you'll replace '''USER''' with your own username...)
* touch ~'''USER'''/share/Foo
* <code>mkdir ~/share</code>
Install Samba
* <code>touch ~/share/Foo</code>
* sudo apt install samba -y
 
Configure the test share
= Install Samba =
* sudo vi /etc/samba/smb.conf
* <code>sudo apt install samba -y</code>
 
= Configure the test share =
* <code>sudo vi /etc/samba/smb.conf</code>
 
== As a publicly accessible share ==
 
[New_share]
    comment= my share
    path = /home/'''USER'''/share
    force create mode = 0660        ; readable and writable by user and group
    force directory mode = 0770    ; readable, writable and searchable by user and group
    browseable  = yes
    Read only = no
    guest  ok = yes
 
'''Note:''' Files & folders placed in this share by an anonymous user will belong to '''nobody:nogroup'''.
:oddly, even as the owner of the share, you won't have direct control over these files/folders.
:So, it might be a good idea to add yourself to the '''nogroup''' group:
:* <code>sudo usermod -a -G nogroup '''USER'''</code>
 
== As a share requiring authentication ==
 
  [New_share]
  [New_share]
     comment= my share
     comment= my share
Line 14: Line 45:
     Read only = no
     Read only = no
     guest  ok = no
     guest  ok = no
    valid users = '''USER'''
 
* sudo systemctl restart smbd
= Restart Samba =
Set up username & password for Samba acess
While you're in there, if you don't have printer(s) connected to the machine, comment out or remove the '''[printers]''' and '''[print$]''' blocks
* sudo smbpasswd -a '''USER'''
 
Additional bits to install (Client & utils & such...)
* <code>sudo systemctl restart smbd</code>
* sudo apt install cifs-utils samba-client -y
 
= Set up usernames & passwords for Samba acess =
(Samba uses it's own password list.&nbsp; Therefore, you'll need to set up each user...)
 
For each user that will be allowed access ('''USER'''s must exist as users on the system),
* <code>sudo smbpasswd -a '''USER'''</code>
 
= Additional bits to install =
Client & utils & such... (optional)
 
In order to be able to [[Mounting CIFS Shares  from the command line{{!}}mount CIFS (Samba, Windows...) shares]] from other servers
* <code>sudo apt install cifs-utils -y</code>
For some reason...
* <code>sudo apt install samba-client -y</code>
seems to be recommended. Gonna hafta research what that actually provides.
 
= Usage Notes =
'''NOTE:''' At this point, the share can be accessed, but you need to know where it is because Samba does not advertise it's presence.
'''NOTE:''' At this point, the share can be accessed, but you need to know where it is because Samba does not advertise it's presence.


You '''can''' see the shares from the machine by entering <code>smb://'''MACHINENAME'''/</code> into the address bar of your file browser.
:You '''can''' see the shares from the machine by entering <code>smb://'''MACHINENAME'''/</code> into the address bar of your file browser.
'''Also... SMB seems to get harder & harder to deal with.''' If just trying to get to the server results in '''Error: Failed to retrieve share list from server: Invalid argument''', it's because of some of the many changes done to the protocols over the years.
 
* <code>sudo vi /etc/samba/smb.conf</code>
& add
 
client min protocol = NT1
server min protocol = NT1
into the '''[global]''' section. (after the "'''workgroup ='''" line is recommended.)
 
== Show shares ==
* <code>sudo smbstatus --shares</code>
 
= Ongoing Research =
Still need to find a way for Samba to properly show up when browsing the network...
 
Hey SAMBA!  How about a solution to the whole "nobody:nogroup" stupidity???
 
[[Category:Linux]]
[[Category: WIP]]

Latest revision as of 13:19, 24 September 2024

Proven on:
Logo Debian.png
11 (bullseye)


Basic Samba install & minimal configuration

Create a test folder & file to be shared.

(Assuming you'll replace USER with your own username...)

  • mkdir ~/share
  • touch ~/share/Foo

Install Samba

  • sudo apt install samba -y

Configure the test share

  • sudo vi /etc/samba/smb.conf

As a publicly accessible share

[New_share]
    comment= my share
    path = /home/USER/share
    force create mode = 0660        ; readable and writable by user and group
    force directory mode = 0770     ; readable, writable and searchable by user and group
    browseable  = yes
    Read only = no
    guest  ok = yes

Note: Files & folders placed in this share by an anonymous user will belong to nobody:nogroup.

oddly, even as the owner of the share, you won't have direct control over these files/folders.
So, it might be a good idea to add yourself to the nogroup group:
  • sudo usermod -a -G nogroup USER

As a share requiring authentication

[New_share]
    comment= my share
    path = /home/USER/share
    browseable  = yes
    Read only = no
    guest  ok = no

Restart Samba

While you're in there, if you don't have printer(s) connected to the machine, comment out or remove the [printers] and [print$] blocks

  • sudo systemctl restart smbd

Set up usernames & passwords for Samba acess

(Samba uses it's own password list.  Therefore, you'll need to set up each user...)

For each user that will be allowed access (USERs must exist as users on the system),

  • sudo smbpasswd -a USER

Additional bits to install

Client & utils & such... (optional)

In order to be able to mount CIFS (Samba, Windows...) shares from other servers

  • sudo apt install cifs-utils -y

For some reason...

  • sudo apt install samba-client -y

seems to be recommended. Gonna hafta research what that actually provides.

Usage Notes

NOTE: At this point, the share can be accessed, but you need to know where it is because Samba does not advertise it's presence.

You can see the shares from the machine by entering smb://MACHINENAME/ into the address bar of your file browser.

Also... SMB seems to get harder & harder to deal with. If just trying to get to the server results in Error: Failed to retrieve share list from server: Invalid argument, it's because of some of the many changes done to the protocols over the years.

  • sudo vi /etc/samba/smb.conf

& add

client min protocol = NT1
server min protocol = NT1

into the [global] section. (after the "workgroup =" line is recommended.)

Show shares

  • sudo smbstatus --shares

Ongoing Research

Still need to find a way for Samba to properly show up when browsing the network...

Hey SAMBA! How about a solution to the whole "nobody:nogroup" stupidity???