I am struggling to have one CentOS machine access a Samba share hosted by another CentOS machine. This is in a mixed OS environment that requires it.
The host is CentOS 7 and for years has hosted files to Windows machines. I have built a new machine based on CentOS however it cannot access the Samba share successfully. Cryptically, Windows 7 virtual machines hosed by this new machine can access the Samba shares just fine, the host itself cannot.
I have disabled selinux setenforce 0
, disabled iptables systemctl stop iptables
and disabled firewalld systemctl stop firewalld
, all on the server. I have tried to make sure the workgroups are the same. I have tried making sure the user and group ids for the same named user are the same on each machine usermod -u <id> <user>
, groupmod -g <id> <user>
.
When using the gnome GUI, the 'Windows Network' cannot be browsed. 'Unable to access location. Failed to retrieve share list from server: No such file or directory'.
When using the 'Connect to Server' with smb://<user>@<ip>/<share>
it asks for the domain and password for which I give the workgroup name and the user password. This is met with 'Unable to access location. Failed to mount Windows share: Connection refused'
When using the terminal with mount.cifs -o username=<user>,workgroup=<workgroup> //<ip>/<share> <mount location>
, I am prompted for a password, upon giving it, the command returns 'Unable to find suitable address'.
When using smbtree
, no results are returned.
What more can I do to understand and resolve this problem?
Linux machines make clumsy Samba clients, as you are discovering. It isn't at all surprising that the Windows guests on the new CentOS machine have no difficulty connecting to the Samba server because they're fully fledged Windows machines, after all, simply connecting through the virtual network on their host and then the LAN to the Samba server. All the CentOS host provides from the Windows guests' perspective is a network connection, its own connection difficulties notwithstanding.
Better between Linux machines to use SSH. SSH server is doubtless already on the Samba server host, because Samba requires it. It's simple enough then to configure login user-wise or for scheduled jobs using key-based (i.e., passwordless) authentication from the new Linux system, so that the connection is transparent to the user. Then, one can use sshfs and a corresponding fstab entry for a local mount point. You'll need to manually line up user accounts on all machines (real and virtual) or think about LDAP or upgrading your Samba server to be a domain controller.
You will have an added bit of complexity if you want the Windows guests on the new CentOS host to have access to local storage on the CentOS host. The optimal configuration for that is a Samba server on the new CentOS host to serve local files to local guests. This quickly takes one down the rabbit hole of configuring multiple Samba servers on the same network, LDAP/Samba AD DC, and perhaps other joy. An alternative might be for the existing Samba host to ssh to the new CentOS machine, mount the latter's storage directories using sshfs & fstab, and then serve those mounts as Samba shares. Regardless, you may find it more elegant simply to skip all this and simply rely on the existing Samba host for file services and associated storage.