How can I share files between a raspberry pi and w

2019-09-26 02:26发布

How can I share files between a raspberry pi and a windows computer? (Like in a public folder or something like that)

2条回答
三岁会撩人
2楼-- · 2019-09-26 02:55

I recommend WinSCP. It's not only easy to share files but also easy to edit and update it.

查看更多
冷血范
3楼-- · 2019-09-26 03:07

There is a lot of confusion about the idea of sharing files. Some folks mean one thing, some folks mean another.

  • Exchanging files or transferring files. By "sharing", some people mean exchanging files or copying files between machines - that means you have to actually physically transfer files between the machines and either means using (old-fashioned) FTP or File Transfer Protocol (often with an FTP client/server like the excellent FileZilla) or the newer scp to Secure Copy files across a network, or copying to a USB memory stick and transferring them physically on foot.

  • Shared directories. In this setup, one machine acts as an SMB/Samba Server and the other as an SMB/Samba client. There are other possible filesystems (such as NFS) but they are not native to Windows, unlike SMB/Samba which is the native Windows network file sharing protocol. To my mind, it is easier to have Windows act as the server since Windows can do that anyway - rather than install and configure sharing software on your Pi. It doesn't make any difference which machine is the server and which is the client really, so let's set up Windows as the server and the Pi as the client so you don't need to install any extra software anywhere.

On Windows machine

Create a shared folder with very insecure permissions until you get set up and working properly - you can always close things down and tighten things up later. So you choose a folder to share, right-click on it and choose "Share" and then set it up for sharing - with loose permissions.

As an alternative, you can do this at the command prompt:

NET SHARE sharename=drive:path

Check that Windows is indeed sharing a folder when you are done. There is no point doing anything on your Raspberry Pi until the following command shows you are sharing a folder from the Windows side.

NET SHARE

On Raspberry Pi

Create a mount point where you would like the Windows files to appear:

sudo mkdir /WINDOWS

Now mount the shared directory so it appears on the Pi:

sudo mount -t cifs -o username=username,password=password //WINDOWS_IP_ADDRESS/share-name /WINDOWS

You can also use the Windows machine name rather than its IP address.

You should now see all your Windows files in /WINDOWS and you should be able to put files there and see them from your Windows machine

If you want to unmount the shared directory:

sudo umount /WINDOWS

If you want to always mount the shared directory when your Pi boots, you need to edit /etc/fstab and add an entry at the bottom along the lines of the mount command above to mount it always at boot:

//WINDOWS_IP_ADDRESS/sharename  /WINDOWS  cifs  guest,uid=1000,iocharset=utf8  0  0

Once it is all working, please consider closing down and tightening up the access permissions.

查看更多
登录 后发表回答