Skip to content

a script that decrease samba protocol security to increase transfer speed

Notifications You must be signed in to change notification settings

raeulein/smb-speed-on-mac

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

smb-speed-on-mac

A script that decrease samba protocol security to increase transfer speed.

As you know, since the AFP protocol for macOS has been deprecated, the default network traffic is now SMB (Server Message Block) also known as Samba. It is notably slower when transferring a large number of small files, which can be very frustrating in daily use. This script, which summarizes adjustments that have been in use for several years, highlights all the settings to modify for faster transfers.

This document explains each line of the provided shell script and its impact on system configuration, particularly in the context of samba/SMB settings on macOS.

Download smb-speed-on-mac.sh script

git clone yokoinc/smb-speed-on-mac

Then edit smb-speed-on-mac.sh to your configuration preferences with your favorite code editor and save

finally run the script as super user

sudo ./smb-speed-on-mac.sh

if script show a permussion erro

sudo chown 755 smb-speed-on-mac.sh

Explanations on the various modifications that this script can make

# Check if the nsmb.conf file exists and remove it if it does
if [ -f /etc/nsmb.conf ]; then
    rm /etc/nsmb.conf
fi
  • Checks if the /private/etc/nsmb.conf file exists, and if so, removes it. This clears any existing SMB configuration, allowing the script to start fresh.
# Create a new nsmb.conf file with default section
echo "[default]" >> /etc/nsmb.conf
  • Creates or appends a [default] section to the /etc/nsmb.conf file to set global configuration parameters.
# Disable SMB signing (decreases security)
echo "signing_required=no" >> /etc/nsmb.conf
  • Disables SMB signing, which ensures the authenticity of data sent over SMB. Disabling this decreases security.
# Disable negotiation validation (decreases security)
echo "validate_neg_off=yes" >> /etc/nsmb.conf
  • Disables SMB negotiation validation, allowing less stringent connection checks. This weakens security.
# Commands with neutral or mixed impact on security
  • Section indicating that the following commands have a neutral or mixed impact on security.
# Enable support for named streams (neutral)
echo "streams=yes" >> /etc/nsmb.conf
  • Enables support for named streams, a feature that allows storage of metadata with files. This is neutral in terms of security.
# Disable change notifications (neutral, but might affect operational efficiency)
echo "notify_off=yes" >> /etc/nsmb.conf
  • Disables change notifications, which may affect operational efficiency by not notifying changes in real time.
# Enable soft mounts (neutral, but could impact data availability)
echo "soft=yes" >> /etc/nsmb.conf
  • Enables “soft” mounting for SMB shares, which can make the connection less reliable in case of network interruptions.
# Disable directory caching (neutral, but impacts performance)
echo "dir_cache_max_cnt=0" >> /etc/nsmb.conf
echo "dir_cache_max=0" >> /etc/nsmb.conf
echo "dir_cache_off=yes" >> /etc/nsmb.conf
  • Disables SMB directory caching, ensuring up-to-date data but impacting performance due to frequent data fetching.
# Commands that improve or do not affect security significantly
  • Comment indicating that the following commands improve security or do not impact it significantly.
# Disable NetBIOS and use direct hosting over TCP/IP (improves security)
echo "port445=no_netbios" >> /etc/nsmb.conf
  • Disables NetBIOS and forces direct hosting over TCP/IP, which improves security by avoiding NetBIOS vulnerabilities.
# Set SMB protocol version to SMB 2 or later (improves security)
echo "protocol_vers_map=4" >> /etc/nsmb.conf
  • Sets the minimum SMB protocol version to SMB 2 (or later), improving security by avoiding older, less secure protocol versions.
# Enable multi-channel support and prefer wired connections (neutral, typically safe)
echo "mc_on=yes" >> /etc/nsmb.conf
echo "mc_prefer_wired=yes" >> /etc/nsmb.conf
  • Enables multi-channel support, allowing multiple network channels to improve transfer speed. Prefers wired connections for stability.
# Prevent creation of .DS_Store files on network shares (neutral, improves performance)
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE

How to remove ...

sudo rm -rm /etc/nsmb.conf
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool FALSE

About

a script that decrease samba protocol security to increase transfer speed

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%