acf domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131all-in-one-wp-migration domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131rocket domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131Once you have your first Linux server up and running, you might be wondering how to transfer files or folders between your server and your local computer. Luckily, there\u2019s an easy solution by setting up a Samba file service on your Cloud Server.<\/p>\n\n\n\n
Samba is a suite of Unix applications that speak the Server Message Block (SMB) protocol. Microsoft Windows operating systems and the OS\/2 operating system use SMB to perform client-server networking for file and printer sharing and associated operations.<\/p>\n\n\n\n
In short, Samba helps you transfer files between your server and your local computer. In this tutorial, we\u2019ll show the steps to set up and configure your Cloud Server with Samba.<\/p>\n\n\n\n
To begin, you need a Linux-based Cloud Server, this can be Ubuntu, Debian or Centos. You can find out more in our tutorial on how to create a new Cloud Server<\/a>.<\/p>\n\n\n\n When your server is live, log in using SSH<\/a> and continue by updating the server software.<\/p>\n\n\n\n Then install Samba with the following command.<\/p>\n\n\n\n We can check if the installation was successful by looking up the installation location.<\/p>\n\n\n\n You should see an output similar to the example below. With Samba installed, we will next configure the firewall.<\/p>\n\n\n\n Depending on your Linux distribution, you will have either ufw or firewalld. If you are running Ubuntu or Debian, UFW is the firewall of choice. CentOS on the other hand comes with firewalld.<\/p>\n\n\n\n You should also allow SSH to prevent yourself from getting locked out.<\/p>\n\n\n\n Next, enable the firewall and the configured rules.<\/p>\n\n\n\n Now let\u2019s verify that the firewall is enabled as well as that Samba and SSH are allowed.<\/p>\n\n\n\n The output should show something like the example below.<\/p>\n\n\n\n Now let\u2019s start configuring Samba. However, before you start, you should always make a backup of the configuration file. This way you always have a way to restore the default settings if something goes wrong.<\/p>\n\n\n\n Open the Samba configuration file with a text editor, for example, using nano with the following command.<\/p>\n\n\n\n Then find the server role setting in the configuration file. The default value should be set to \u201cstandalone server\u201d.<\/p>\n\n\n\n Now let\u2019s test our configuration file with the command below.<\/p>\n\n\n\n If there are no errors, your output should show the configuration as well as say \u201cLoaded services file ok\u201d like the example above.<\/p>\n\n\n\n Let\u2019s restart the related services to make sure everything is running. Now that Samba is installed, we need to create a directory for it to share, this makes it more organised.<\/p>\n\n\n\n The command above creates a new folder called samba in the system root which we will share later.<\/p>\n\n\n\n Now let\u2019s set the group ownership of the shared directory to the sambashare group which was created during the Samba installation.<\/p>\n\n\n\n Samba utilises both Linux users and group permission as well as its own mechanism.<\/p>\n\n\n\n Let\u2019s create a user account using the useradd<\/tt> command. You can replace the example username upcloud with what you prefer.<\/p>\n\n\n\n Breaking down the above command you just entered.<\/p>\n\n\n\n Now create a home directory for our user upcloud, then set the group of the folder to the samba share.<\/p>\n\n\n\n Once this is done, we will set a password for the Samba user account<\/p>\n\n\n\n You will be prompted to enter and confirm the user password.<\/p>\n\n\n\n Once the password is set and the user is created, enable the user with the following.<\/p>\n\n\n\n Next, we will set the setGID bit into the Samba directory. This will cause all files that are created in the shared directory to be owned by the group of the directory as opposed to the group of the owner.<\/p>\n\n\n\n Lastly, we need to tell Samba where the shared directory is and who has permission to it.<\/p>\n\n\n\n Open the Samba configuration file for editing.<\/p>\n\n\n\n Add the following lines to the end of the file.<\/p>\n\n\n\n When done, save the file and exit the editor.<\/p>\n\n\n\n Then restart the Samba services<\/p>\n\n\n\n Once this is done, you are ready to connect to the Samba directory from your local machine.<\/p>\n\n\n\n For Windows users, you can connect to the Samba directory via the Windows Explorer.<\/p>\n\n\n\n 1. Click on Start and search for \u201cFile Explorer\u201d then open it<\/p>\n\n\n\n 2. In the window, right-click on \u201cThis PC\u201d then select \u201cMap network drive\u201d 3. A Popup will show asking for the credentials, Insert the user credentials, and set in the smbpasswd portion in Setting up User Accounts. For this eg, it will be \u201cupcloud\u201d 4. The folder is now connected. I have added a file to the folder and the file is shown in my Windows network drive. In macOS, you can access the Samba Shares either from the command line or using the default macOS file manager Finder. The following steps show how to access the share using Finder.<\/p>\n\n\n\n 1. Open \u201cFinder\u201d, select \u201cGo\u201d and click \u201cConnect To\u201d. 2. In \u201cConnect To\u201d, enter the address of the Samba share in the following format smb:\/\/samba_hostname_or_server_ip\/sharename. 3. Make sure you select registered user and key in your Linux Credentials. In this eg, that will be upcloud 4. Once it is connected you will be able to see the files from the server. On most Linux distributions, you can use a Samba command-line client. For example, smbclient can be installed on Ubuntu and other Debian-based systems using the following command. 1. For example, on Ubuntu Nautilus, click the \u201c+Other Locations\u201d on the left panel. Then enter your Samba server address and share name in the \u201cConnect to Server\u201d field and click the Connect button.<\/p>\n\n\n\n 2. In the authentication window, select use Registered User and enter your username and password.<\/p>\n\n\n\n You can also choose to have the username and password remembered either for the duration of the current login or permanently.<\/p>\n\n\n\n 3. You are then ready to start uploading files to your Samba Linux server.<\/p>\n\n\n\n You should now be able to transfer files from your local computer to your Cloud Server and back.<\/p>\n\n\n\nsudo apt update && sudo apt upgrade<\/code><\/p>\n\n\n\nsudo apt install samba<\/code><\/p>\n\n\n\nwhereis samba<\/code><\/p>\n\n\n\nsamba: \/usr\/sbin\/samba \/usr\/lib\/samba \/etc\/samba \/usr\/share\/samba \/usr\/share\/man\/man7\/samba.7.gz \/usr\/share\/man\/man8\/samba.8.gz<\/code><\/p>\n\n\n\n sudo ufw allow 'Samba' <\/code><\/p>\n\n\n\n sudo ufw allow ssh<\/code><\/p>\n\n\n\n sudo ufw enable <\/code><\/p>\n\n\n\n sudo ufw status verbose <\/code><\/p>\n\n\n\nStatus: active
\nLogging: on (low)
\nDefault: deny (incoming), allow (outgoing), disabled (routed)
\nNew profiles: skip
\nTo Action From
\n-- ------ ----
\n137,138\/udp (Samba) ALLOW IN Anywhere
\n139,445\/tcp (Samba) ALLOW IN Anywhere
\n22\/tcp ALLOW IN Anywhere
\n137,138\/udp (Samba (v6)) ALLOW IN Anywhere (v6)
\n139,445\/tcp (Samba (v6)) ALLOW IN Anywhere (v6)
\n22\/tcp (v6) ALLOW IN Anywhere (v6)
\n<\/code><\/p>\n\n\n\nVerifying the default configuration<\/h2>\n\n\n\n
sudo cp \/etc\/samba\/smb.conf{,.backup}<\/code><\/p>\n\n\n\n sudo nano \/etc\/samba\/smb.conf <\/code><\/p>\n\n\n\n ...
\n# Most people will want \"standalone sever\" or \"member server\".
\n# Running as \"active directory domain controller\" will require first
\n# running \"samba-tool domain provision\" to wipe databases and create a
\n# new domain.
\nserver role = standalone server
\n...<\/code><\/p>\n\n\n\ntestparm<\/code><\/p>\n\n\n\nLoad smb config files from \/etc\/samba\/smb.conf
\nLoaded services file OK.
\nServer role: ROLE_STANDALONE<\/code><\/p>\n\n\n\nsudo systemctl restart smbd
\nsudo systemctl restart nmbd<\/code><\/p>\n\n\n\nSetting up Samba<\/h2>\n\n\n\n
mkdir \/samba<\/code><\/p>\n\n\n\n sudo chgrp sambashare \/samba<\/code><\/p>\n\n\n\nSetting up a user account<\/h2>\n\n\n\n
sudo useradd -M -d \/samba\/upcloud<\/span> -s \/usr\/sbin\/nologin -G sambashare upcloud<\/span><\/code><\/p>\n\n\n\n\n
sudo mkdir \/samba\/upcloud <\/code><\/p>\n\n\n\n sudo chown upcloud:sambashare \/samba\/upcloud <\/code><\/p>\n\n\n\nsudo smbpasswd -a upcloud<\/code><\/p>\n\n\n\n New SMB password:
\nRetype new SMB password:
\nAdded user upcloud.<\/code><\/p>\n\n\n\n sudo smbpasswd -e upcloud <\/code><\/p>\n\n\n\n sudo chmod 2770 \/samba\/upcloud <\/code><\/p>\n\n\n\nConfiguring Samba configuration file<\/h2>\n\n\n\n
sudo nano \/etc\/samba\/smb.conf <\/code><\/p>\n\n\n\n[upcloud]
\npath = \/samba\/upcloud
\nbrowseable = no
\nread only = no
\nforce create mode = 0660
\nforce directory mode = 2770
\nvalid users = upcloud<\/code><\/p>\n\n\n\n sudo systemctl restart smbd
\nsudo systemctl restart nmbd<\/code><\/p>\n\n\n\nAccessing Samba Share from Windows<\/h2>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\nAccessing Samba Share from macOS<\/h2>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\nAccessing Samba share from Ubuntu<\/h2>\n\n\n\n
sudo apt install smbclient<\/code>
Once installed, you can connect to your Samba share with the command below.smbclient \/\/samba_hostname_or_server_ip\/sharename -U username<\/code>
For example, using the Cloud Server IP address and the \u201cupcloud\u201d share we created earlier. You\u2019ll also need to use the -U parameter for specifying the login username.smbclient \/\/94.237.60.118\/upcloud -U upcloud<\/code>
When prompted, enter your passwordEnter WORKGROUPupcloud's password:
Try \"help\" to get a list of possible commands.
smb: ><\/code>
Alternatively, you can add your Samba share to most native file managers.<\/p>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\nConclusion<\/h2>\n\n\n\n