I have a linux server and a Windows server. On Linux was installed and configured Samba to share 2 directories to the windows server. In /etc/samba/smb.conf we have:
[Myapp PDF Reports]
comment = Reports
browseable = yes
path = /var/www/myapp/reports_pdf
printable = no
guest ok = no
read only = no
create mask = 0700
[Myapp PDF Vault]
comment = PDF Vault
browseable = yes
path = /var/www/myapp/PDFvault
printable = no
guest ok = no
read only = no
create mask = 0700
In windows I see the 2 shares under the linux server, but I don't know which user I have to use to connect to them (unfortunatly I can't ask to the person implemented them some years ago). How can I see in Linux r Windows which is the user with the right permission to access these 2 shares and then get the relative password?
Kind regards, Matteo
CodePudding user response:
If you login to the Samba server, you can run the following command to list valid Samba users:
sudo pdbedit -L -v
The above command will list users known to Samba - this is not the same as the users and passwords known the Linux server it is running on. Read that last sentence again.
If you don't know the passwords for the old users, you have a couple of choices:
- change the password of an old, existing user to something new, or
- add a new user with a new password that you can use.
I think the first option is less desirable because it means if there are clients that know the old password and you change it, they will suddenly stop working.
So, I would add a new Samba user. This new user must have a login name on the Samba server, so either choose an existing Linux username you want to use, or add a new one. I choose to use the Linux username nobody
because it exists on most systems. So, all you need to do is:
- add
nobody
as a Samba user - set the Samba password for
nobody
- use those credentials when mounting a Samba share
That looks like:
sudo smbpasswd -a nobody # add nobody user
sudo smbpasswd -e nobody # enable nobody
Now you should be able to mount the shares with username=nobody
and the password you just set.
CodePudding user response:
Do not give the user 'nobody' a Samba password. The user 'nobody' is used with 'map to guest = bad user' in the global section of smb.conf and with 'guest ok = yes' in a share. If these are set, then Samba will map any unknown users to the guest user and all files created on the share will belong to nobody:nogroup.
If you need to create a new user, you must first create a Linux user and then make that user a Samba user with 'smbpasswd -a username' run as root, where 'username' is the name of the Linux user you just created.