Advertisement
Tritonio

Share a folder with a Windows computer from a Raspberry Pi

Mar 15th, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1.  
  2.  
  3. Sharing files over the network is often very useful. Whether you need to transfer media files to the Raspberry Pi or you want to use the raspberry as a simple Network-Attached Storage (NAS) device, this guide will show you how to enable file sharing of a folder on the Raspberry Pi running the Raspbian OS.
  4.  
  5. Prerequisites & Equipment
  6.  
  7. You are going to need the following:
  8.  
  9. A Raspberry Pi (Buy here)
  10. A SD Card flashed with the Raspbian OS (Here is a guide if you need)
  11. Access to the Raspberry either via keyboard and a monitor or remotely
  12. A home network
  13. A Windows computer (for this guide we will be running Windows 7)
  14.  
  15. Install and configure required software
  16.  
  17. To share network folders to a Windows computer we need to install some special software on the Raspberry Pi. The software providing the secret sauce this time is called Samba. The Samba software package implements the SMB protocol and provides support for the Windows naming service (WINS) and for joining a Windows Workgroup.
  18.  
  19. Installing the software is easy – login to your Raspberry Pi and run:
  20.  
  21. sudo apt-get install samba samba-common-bin
  22.  
  23. After installation configure the software by opening the file /etc/samba/smb.conf using the command:
  24.  
  25. sudo nano /etc/samba/smb.conf
  26.  
  27. Read through the file and make sure you have the following parameters set:
  28.  
  29. workgroup = WORKGROUP
  30. wins support = yes
  31.  
  32. You can use anything as your workgroup name as long as it is alphanumerical and matches the workgroup you would like to join. The default workgroup in Windows 7 is WORKGROUP.
  33. Setup folder to share
  34.  
  35. Next step is to create the folder you would like to share. To create a folder called “share” in your home directory do the following:
  36.  
  37. mkdir ~/share
  38.  
  39. With the folder created we can now tell the Samba software to share it on the network. Open the file /etc/samba/smb.conf using the command:
  40.  
  41. sudo nano /etc/samba/smb.conf
  42.  
  43. Scroll to the bottom and add the following:
  44.  
  45. [PiShare]
  46. comment=Raspberry Pi Share
  47. path=/home/pi/share
  48. browseable=Yes
  49. writeable=Yes
  50. only guest=no
  51. create mask=0777
  52. directory mask=0777
  53. public=no
  54.  
  55. Notice how we tell Samba that public access is not allowed via “public=no” – this means that anyone wanting to access the shared folder must login with a valid user.
  56.  
  57. In this case the valid user is the user called “pi”. To let Samba know that “pi” is a network user run the command:
  58.  
  59. sudo smbpasswd -a pi
  60.  
  61. And enter pi’s password twice (default: raspberry).
  62.  
  63. At this point we can now login to the share from our Windows computer – use Domain: raspberrypi, User: pi and Password: raspberry (unless you changed the password) as you can see below:
  64.  
  65. Login to shared folder on Raspberry Pi
  66.  
  67. If you do not want to deal with logging in you can always make the share publicly available by changing the config file to say:
  68.  
  69. public=yes
  70.  
  71. However please note that this is extremely dangerous since anyone will be able to access, modify and delete your files.
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement