1

I have two Ubuntu machines which I access via terminal (over PuTTY) on a Windows machine.

I use a script on one Ubuntu machine to create network shares (and users to access them) and a script on the other Ubuntu machine to mount those shares. The share creation script uses the following lines of code for each share to be created:

chmod -R 777 /media/hdd/shares/$Username
useradd $Username
(echo $Password; echo $password) | smbpasswd -a -s $Username
echo >> /etc/samba/smb.conf
echo [$Username] >> /etc/samba/smb.conf
echo path = /media/hdd/shares/$Username >> /etc/samba/smb.conf
echo browsable = yes >> /etc/samba
echo read only = no >> /etc/samba/smb.conf
echo writable = yes >> /etc/samba/smb.conf
echo valid users = $Username >> /etc/samba/smb.conf

(before any of this takes places, the script restores the smb.conf file to its default, shareless state)

This code is iterated through twice with a different $Username and $Password both times. The $Username and $Password values are stored in a file that both Ubuntu machines have access to, so that the other one can use the same values and mount the shares. This comes off without a hitch; both of the shares mount on the other machine.

However, on Windows I'm only able to mount one of the two shares. I'm completely at a loss for how to even troubleshoot this. I suspect there may be a difference between the two user accounts but I don't know where to check.

I need both shares to mount on Windows. How can I resolve this?

EDIT: Solved. By switching "valid users" to "force user" it behaves as expected now. No idea what difference this makes.

EDIT 2: Not actually solved. Switching to "force user" allows any share to be accessed by any valid set of credentials. I've gone back to using "valid users". The issue has gotten more interesting after a friend used another windows PC (both of us are Win10 1709) to try connecting to the shares and he is able to connect only to the share that I can't reach.

  • Valid user and forced user are two very different things. Forcing a user means that all file operations are performed as that user. This means either one of your users can now connect to either share but all actions they take appear as the forced user. – B. Miller Jun 1 '18 at 1:33
  • Side note (a hint): research here documents. The syntax cat >>/etc/samba/smb.conf <<EOF will make your code much clearer. – Kamil Maciorowski Jun 1 '18 at 5:49
  • Thank you, B. Miller. That's important and I didn't think to test it. Kamil, I'm not playing warmer/colder on StackExchange of all places. I'm here because I've tried everything else I could think of and I need answers, not games. – Bo Thompson Jun 1 '18 at 17:22

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.