Access SAMBA Drive Denied: SSH Ping Working on Two Devices

Abstract: Resolve Samba access denied errors on Linux by configuring firewalld or ufw to allow TCP ports 139 and 445 and verifying smb.conf authentication settings.

Created: 2026-09-27 by

When SSH connectivity works but Samba access fails, the issue typically stems from misconfigured firewall rules blocking port 445 or incorrect authentication settings in smb.conf. Since ICMP and SSH traffic succeed, network reachability is confirmed, pointing to application-layer restrictions rather than basic connectivity problems. This guide details how to diagnose and resolve these specific permission denied errors on Linux servers.

Differentiating Network Reachability from Service Availability

It is crucial to understand that a successful ping and SSH login prove Layer 3 (Network) and Layer 4 (Transport) connectivity for specific protocols. However, Samba relies on SMB/CIFS protocols which operate over TCP ports 139 and 445. If your server’s firewall allows SSH (port 22) and ICMP but blocks high-numbered TCP ports, clients will connect via SSH but fail when attempting to mount the share. Many users mistakenly assume that because they can log into the machine via terminal, file sharing should automatically work. This is not the case. The operating system treats these as distinct services with independent security policies. You must verify that the firewall explicitly permits inbound connections to the Samba ports. On modern Linux distributions using firewalld, you might see rules allowing ssh but lacking entries for samba or cifs. Similarly, if you are using iptables directly, ensure there are no DROP rules targeting destination port 445.

Verifying Firewall Configuration

The most common culprit for this symptom is an overly restrictive firewall. Start by checking the status of your active firewall service. For systems using firewalld, run the following command to list all allowed services:
sudo firewall-cmd --list-all
Look for ports: or services: in the output. If you do not see port 445/tcp or the service name samba, you need to add it. Use these commands to permanently allow Samba traffic:
sudo firewall-cmd --permanent --add-service=samba
sudo firewall-cmd --reload
If you are using ufw (Uncomplicated Firewall), check its status with sudo ufw status. You may need to enable the profile or manually allow the port:
sudo ufw allow samba
sudo ufw reload
After adjusting the firewall, test connectivity again. Note that some cloud providers also have security groups at the hypervisor level. Ensure your instance’s security group permits inbound TCP traffic on ports 139 and 445 from your client’s IP address. This is often overlooked because the SSH rule usually exists, leading to false confidence in network accessibility.

Inspecting Samba Authentication Settings

If the firewall is correctly configured, the next likely cause is authentication failure within the Samba configuration itself. Samba maintains its own password database separate from the system’s user accounts. A user might exist on the OS and be able to SSH in, but lack a valid Samba password hash. Check the global section of your /etc/samba/smb.conf file. Look for the map to guest directive. If set to bad user or never, anonymous access is disabled, requiring valid credentials. Verify that the shared directory has the correct permissions defined in the config:
[myshare]
   path = /srv/samba/myshare
   browseable = yes
   read only = no
   valid users = username
   create mask = 0664
   directory mask = 0775
Ensure that the valid users line includes the account you are trying to use. If you recently changed the Linux user password, you must update the Samba password as well. Use the smbpasswd command to add or modify the Samba-specific password:
sudo smbpasswd -a username
Restart the Samba services to apply any configuration changes:
sudo systemctl restart smbd nmbd

Checking SELinux and AppArmor Policies

On enterprise-grade Linux distributions like RHEL, CentOS, or Fedora, SELinux can block Samba access even if firewalls and permissions are correct. SELinux enforces mandatory access controls that restrict what processes can touch which files. If Samba tries to serve files from a directory labeled incorrectly, it will return a permission denied error. Check the SELinux context of your share directory using ls -Z. It should ideally have a context like samba_share_t. If it does not, you can relabel it using the semanage tool:
sudo semanage fcontext -a -t samba_share_t "/srv/samba/myshare(/.*)?"
sudo restorecon -Rv /srv/samba/myshare
You can also check SELinux audit logs for denials related to Samba:
sudo ausearch -m avc -ts recent | grep smbd
For Ubuntu and Debian systems, AppArmor serves a similar function. Check if the Samba daemon is confined and if any profiles are logging denials in /var/log/syslog. While less common than firewall issues, strict MAC (Mandatory Access Control) policies can silently block access without obvious error messages in standard logs.

Testing Client-Side Resolution

Sometimes the issue lies with how the client resolves the server hostname or IP. DNS caching issues or incorrect hosts file entries can cause intermittent failures. Try accessing the share using the direct IP address instead of the hostname to rule out resolution problems. Use the smbclient tool to test connectivity from the command line:
smbclient //IP_ADDRESS/share_name -U username
If this command succeeds, the server is reachable and authenticated properly. The issue then lies with the client’s mounting process or GUI frontend. If it fails, review the error message carefully. A "Connection refused" indicates a firewall or service down issue, while "Access Denied" points to authentication or permission mismatches. For more detailed troubleshooting on connection stability, consider reviewing Troubleshooting SSH Connection Issues on Linux. Additionally, if you encounter symlink-related errors within the share, check Symlinks in Samba Share Created on Linux Client Not Working on Server.

Frequently Asked Questions

Why does my Samba share show as inaccessible even though I can ping the server?

Pinging only verifies ICMP echo requests, which are different from TCP connections used by Samba. Your firewall may be allowing ICMP and SSH traffic while actively blocking TCP ports 139 and 445. You must explicitly configure your firewall to permit SMB/CIFS traffic.

How do I reset my Samba password if I forgot it?

You can reset the Samba password using the smbpasswd command. Run sudo smbpasswd username to change an existing user's password, or sudo smbpasswd -a username to add a new user to the Samba database. This password is separate from your Linux system login password.

What causes "Permission Denied" after entering the correct password?

This usually indicates that the Linux file system permissions on the shared directory are too restrictive, or SELinux/AppArmor is blocking access. Ensure the owning user has read/write rights to the folder and that the valid users directive in smb.conf matches the authenticating user.

Can I disable authentication for a Samba share entirely?

Yes, you can enable guest access by setting map to guest = bad user in the global section and guest ok = yes in the share definition. However, this exposes your data to anyone on the network and is generally discouraged for sensitive information.

Why does Windows fail to map the drive while Linux mounts it successfully?

Windows requires SMB version 2 or higher, while older Linux configurations might default to SMB1. Ensure your smb.conf specifies server min protocol = SMB2. Additionally, Windows may cache old credentials; try clearing the stored passwords in the Windows Credential Manager before remapping.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More