How to create Samba share on Linux for guests to access on your network

[ad_1]

4 penguins standing in a circle

Mihaita Costin/500px/Getty Images

Samba is a great way to share folders from your Linux desktop with other users on your network. For example, you might have documents that others need to access — or perhaps you have photos, video, or just about any type of file to share. Samba makes it possible to share those files and folders to any device on your network and do so with a required username and password. 

I’ve already explained how Samba can be set up in this way. But this time around I want to demonstrate how you can create a share that doesn’t require a username or password for users to access, so you can make those files available to anyone connected to your network.

Also: Two tricks that make using the Linux command line a lot easier

One thing to keep in mind is that you should never share files with sensitive information in this way. For those types of files you want to ensure your shares are set up for authentication; otherwise, that sensitive information could wind up in the wrong hands. In other words, use caution when doing this.

Before you jump into creating the guest folder, make sure to read through the piece linked above, so you can get Samba installed and understand how it works. In that piece, you create a password-protected share that can only be accessed by those who have accounts on the machine sharing the directory.

Once you’re familiar with Samba, it’s time to create the guess-accessible directory.

How to create your guest share with Samba

What you’ll need: To make this work, you’ll need a Linux machine running Samba and a user with sudo privileges. That’s it. Let’s get to work.

The first thing we’ll do is create the directory that will house the files/folders accessible by guests on your network. To do that, open your terminal window and issue the following command:

We now must change the permissions for the folder, such that anyone can access it with the command:

Next, we need to open the Samba configuration file with the following command:

sudo nano /etc/samba/smb.conf

Also: How to share a printer on Linux with CUPS and Samba

Since we’re making this share available to anyone, we want to lock down Samba such that it’s only accessible from your internal network. To do this, you must change two lines. Before doing this, you must locate the name associated with your network interface, which can be done with the command:

You should see a name for that interface, such as enp0s3.

The first thing you must change is this:

; interfaces = 127.0.0.0/8 eth0

Change that to:

interfaces = 127.0.0.0/8 NAME

Where NAME is the name of your network interface.

Next, locate the following line:

; bind interfaces only = yes

Change that to:

bind interfaces only = yes

At the bottom of the smb.conf file, add the following:

[public]
path = /home/share
public = yes
guest only = yes
writable = yes
force create mode = 0666
force directory mode = 0777
browseable = yes

The above configuration defines the path to the share; makes it public, guest only, and writable; sets the permission mode for file creation and directories; and makes it browsable.

Also: Linux distro hopping is a fun way to find the perfect desktop operating system

Save and close the file with the Ctrl+X key combination.

Finally, you can restart Samba so the guest share takes effect. To do that, issue the command:

sudo systemctl restart smbd

Once Samba has restarted, you should be able to access that share as a guest, without having to type a username or password. 

This is a great way to allow any user on your network access to a specific directory. Just remember not to add sensitive files to that location; otherwise, they could wind up in the wrong hands.



[ad_2]

Source link