Configure shared folder to be mountable without authentication
My ultimate goal is to configure an HP Officejet Pro 8600 to save scans into a shared folder on my computer (using the "Scan to network folder" functionality of the printer).
So I have configured a folder on my computer as a network share in the following way:
$ net usershare info --long
[LocalNetwork]
path=/path/to/LocalNetwork
comment=
usershare_acl=Everyone:F,
guest_ok=y
I have also configured my UFW firewall to allow access from within the local network to the ports used by Samba:
$ sudo ufw allow from 192.168.178.0/24 to any app Samba
Rule added
$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
137,138/udp (Samba) ALLOW IN 192.168.178.0/24
139,445/tcp (Samba) ALLOW IN 192.168.178.0/24
Both the printer and my computer are in the same network and I use \\<my-ip-address>\LocalNetwork
as the network path. Since the printer reports "Connection failed" when testing
the connection, I decided to test it with a Raspberry Pi that is in the same network. When I attempt to mount the folder though, it asks for a password for the root
user:
$ sudo mount -t cifs //192.168.178.92/LocalNetwork test_mount_point
Password for root@//192.168.178.92/LocalNetwork:
I didn't expect this, since I configured the folder for guest access. So why does it attempt to authenticate and how can I setup the folder to be accessible without authentication?
Edit
By passing -o guest
it doesn't prompt for a password, however I get a mount error(13): Permission denied
:
$ sudo mount -t cifs -o guest //192.168.178.92/LocalNetwork test_mount_point
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Edit
Following this answer I have added a user via smbpasswd
with some password (nopass
):
$ sudo smbpasswd -a nobody
When I try to mount the folder using this username and password I get a new error however:
$ sudo mount -v -t cifs -o user=nobody,password=nopass //192.168.178.92/LocalNetwork test_mount_point
mount error(5): Input/output error
Edit: testparm -s
This is the output:
$ testparm -s
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Server role: ROLE_STANDALONE
# Global parameters
[global]
log file = /var/log/samba/log.%m
logging = file
map to guest = Bad User
max log size = 1000
obey pam restrictions = Yes
pam password change = Yes
panic action = /usr/share/samba/panic-action %d
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
passwd program = /usr/bin/passwd %u
server role = standalone server
server string = %h server (Samba, Ubuntu)
unix password sync = Yes
usershare allow guests = Yes
usershare owner only = No
idmap config * : backend = tdb
[LocalNetwork]
create mask = 0777
guest ok = Yes
path = /path/to/LocalNetwork
read only = No
As it turns out I have an HP8600 in my network and I couldn't reproduce your problem when I set the Network Folder on the HP to a Xubuntu 18.04 machine.
But I did get the exact same Connection Refused error when I tested it against an Ubuntu 20.04 machine.
It would appear that either because of its age or the method it's using to connect to the samba share it is doing so using the 1.0 version of the SMB dialect. There is no SMB1 ( samba calls it NT1 ) on the server side of Samba in Ubuntu 20.04 ... but you can enable it if you want:
Edit /etc/samba/smb.conf and right under the force user = your-user-name that I suggested above add this one:
server min protocol = NT1
Then restart smbd: sudo service smbd restart
You may need to reboot the ubuntu box. Now I can send it to the Ubuntu 20 share.
Some notes about things that have come up here:
-
You need to make a decision about how you want to create shares.
You created a usershare ( Local Network Share ) of the target folder in Nautilus then you created a classic share in smb.conf. It's best to create them one way or the other if you want to share a particular folder. So my suggestion would be to remove one of the shares for this folder.
-
Force user happens after the client makes the connection not before.
-
Where you place the "force user" depends on how you created the share.
If you create all your shares through Nautilus place it in the [global] sections as I suggested above. If you create the shares within smb.conf then add it to the share definition there.
-
Without the "force user" you will end up with the scanned file being owned by "nobody" not you.
-
And you should remove nobody from the samba password database since it's not meant to be used the way you are using it:
sudo smbpasswd -x nobody