{"id":241949,"date":"2022-05-13T09:11:55","date_gmt":"2022-05-13T01:11:55","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=241949"},"modified":"2022-05-04T19:13:45","modified_gmt":"2022-05-04T11:13:45","slug":"linux-windows-files","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-windows-files.html","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 Samba\u5728 Linux \u548c Windows\u4e4b\u95f4\u8bbe\u7f6e\u6587\u4ef6\u5171\u4eab\uff1f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5982\u679c\u4f60\u4f7f\u7528\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u80fd\u591f\u5728\u5b83\u4eec\u4e4b\u95f4\u5171\u4eab\u6587\u4ef6\u4f1a\u8ba9\u4f60\u500d\u611f\u65b9\u4fbf\u3002\u8fd9\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Samba \u548c mount.cifs \u5728 Linux (Fedora 33)\u548c Windows 10 \u4e4b\u95f4\u8bbe\u7f6e\u6587\u4ef6\u5171\u4eab\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Samba \u662f SMB\/CIFS \u534f\u8bae\u7684 Linux \u5b9e\u73b0\uff0c\u5141\u8bb8\u901a\u8fc7\u7f51\u7edc\u8fde\u63a5\u76f4\u63a5\u8bbf\u95ee\u5171\u4eab\u7684\u6587\u4ef6\u5939\u548c\u6253\u5370\u673a\u3002 mount.cifs \u662f Samba \u5957\u4ef6\u7684\u4e00\u90e8\u5206\uff0c\u53ef\u8ba9\u4f60\u5728 Linux \u4e0b\u6302\u8f7d CIFS \u6587\u4ef6\u7cfb\u7edf\u3002<\/p>\n

\u6ce8\u610f:<\/strong>\u00a0\u8fd9\u4e9b\u8bf4\u660e\u9002\u7528\u4e8e\u5728\u4f60\u7684\u79c1\u6709\u672c\u5730\u7f51\u7edc\u5185\uff0c\u6216\u5728 Linux \u5bbf\u4e3b\u673a\u548c\u865a\u62df\u5316\u7684 Windows \u8bbf\u5ba2\u673a\u4e4b\u95f4\u7684\u865a\u62df\u4e3b\u673a\u4e13\u7528\u7f51\u7edc\u4e2d\u5171\u4eab\u6587\u4ef6\u3002\u4e0d\u8981\u5c06\u672c\u6587\u89c6\u4e3a\u4f60\u516c\u53f8\u7f51\u7edc\u7684\u64cd\u4f5c\u6307\u5357\uff0c\u56e0\u4e3a\u672c\u6587\u6ca1\u6709\u5b9e\u73b0\u5fc5\u8981\u7684\u7f51\u7edc\u5b89\u5168\u8003\u8651\u3002<\/p>\n

\u4ece Windows \u8bbf\u95ee Linux<\/strong><\/div>\n

\u672c\u8282\u4ecb\u7ecd\u4ece Windows \u6587\u4ef6\u8d44\u6e90\u7ba1\u7406\u5668\u8bbf\u95ee\u7528\u6237\u7684 Linux \u4e3b\u76ee\u5f55\u3002<\/p>\n

1\u3001\u5b89\u88c5\u548c\u914d\u7f6e Samba<\/strong><\/span><\/div>\n

\u8fdb\u5165\u4f60\u7684\u7cfb\u7edf\u5b89\u88c5 Samba:<\/p>\n

dnf install samba<\/pre>\n

Samba \u662f\u4e00\u4e2a\u7cfb\u7edf\u5b88\u62a4\u8fdb\u7a0b\uff0c\u5176\u914d\u7f6e\u6587\u4ef6\u4f4d\u4e8e \/etc\/samba\/smb.conf\u3002\u5b83\u7684\u9ed8\u8ba4\u914d\u7f6e\u5e94\u8be5\u5c31\u53ef\u4ee5\u5de5\u4f5c\u3002\u5982\u679c\u4e0d\u884c\uff0c\u4e0b\u9762\u8fd9\u4e2a\u6700\u5c0f\u5316\u914d\u7f6e\u5e94\u8be5\u53ef\u4ee5\u89e3\u51b3\u95ee\u9898\uff1a<\/p>\n

[global]\r\nworkgroup = SAMBA\r\nserver string = %h server (Samba %v)\r\ninvalid users = root\r\nsecurity = user\r\n[homes]\r\ncomment = Home Directories\r\nbrowseable = no\r\nvalid users = %S\r\nwritable = yes<\/pre>\n

\u4f60\u53ef\u4ee5\u5728\u8be5\u9879\u76ee\u7f51\u7ad9\u7684 smb.conf \u90e8\u5206\u627e\u5230\u53c2\u6570\u7684\u8be6\u7ec6\u8bf4\u660e\u3002<\/p>\n

2\u3001\u4fee\u6539 LinuxSE<\/strong><\/span><\/div>\n

\u5982\u679c\u4f60\u7684 Linux \u53d1\u884c\u7248\u53d7 SELinux \u4fdd\u62a4(\u6bd4\u5982 Fedora)\uff0c\u5fc5\u987b\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u624d\u80fd\u901a\u8fc7 Samba \u5171\u4eab\u4e3b\u76ee\u5f55\uff1a<\/p>\n

\n
\n
\n
\n
<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n
setsebool -P samba_enable_home_dirs on\r\n\r\n\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u8fd9\u4e2a\u503c\uff1a<\/pre>\n
getsebool samba_enable_home_dirs<\/pre>\n

\u8f93\u51fa\u5982\u4e0b\uff1a<\/p>\n

\"\"<\/p>\n

3\u3001\u542f\u7528\u4f60\u7684\u7528\u6237<\/strong><\/span><\/div>\n

Samba \u4f7f\u7528\u4e00\u7ec4\u7528\u6237\/\u5bc6\u7801\u6765\u7ba1\u7406\u8fde\u63a5\u6743\u9650\u3002\u901a\u8fc7\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u5c06\u4f60\u7684 Linux \u7528\u6237\u6dfb\u52a0\u5230\u8be5\u96c6\u5408\u4e2d\uff1a<\/p>\n

smbpasswd -a <\u4f60\u7684\u7528\u6237\u540d><\/p>\n

\u7cfb\u7edf\u63d0\u793a\u4f60\u8f93\u5165\u5bc6\u7801\u3002\u8fd9\u662f\u4e00\u4e2a \u5168\u65b0 \u7684\u5bc6\u7801;\u800c\u4e0d\u662f\u4f60\u8d26\u6237\u7684\u5f53\u524d\u5bc6\u7801\u3002\u8bf7\u8f93\u5165\u4f60\u60f3\u7528\u6765\u767b\u5f55 Samba \u7684\u5bc6\u7801\u3002<\/p>\n

\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u5f97\u5230\u6709 Samba \u4f7f\u7528\u6743\u9650\u7684\u7528\u6237\u5217\u8868\uff1a<\/p>\n

pdbedit -L -v<\/pre>\n

\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\u4e00\u4e2a\u7528\u6237\uff1a<\/p>\n

smbpasswd -x <\u7528\u6237\u540d><\/pre>\n
4\u3001\u5f00\u542f Samba<\/strong><\/span><\/div>\n

\u65e2\u7136 Samba \u662f\u4e00\u4e2a\u7cfb\u7edf\u5b88\u62a4\u8fdb\u7a0b\uff0c\u4f60\u53ef\u4ee5\u5728 Fedora \u4e0a\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u5b83\uff1a<\/p>\n

systemctl start smb<\/pre>\n

\u8fd9\u5c06\u4e3a\u5f53\u524d\u4f1a\u8bdd\u5f00\u542f Samba \u670d\u52a1\u3002\u5982\u679c\u60f3\u8ba9\u5b83\u81ea\u542f\u52a8\uff0c\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

systemctl enable smb\r\n\r\n\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e0a\uff0cSamba \u5b88\u62a4\u8fdb\u7a0b\u6ce8\u518c\u4e3a smbd\u3002<\/pre>\n
5\u3001\u914d\u7f6e\u9632\u706b\u5899<\/strong><\/span><\/div>\n

\u4f60\u7684\u9632\u706b\u5899\u4f1a\u9ed8\u8ba4\u963b\u62e6 Samba\u3002\u901a\u8fc7\u914d\u7f6e\u9632\u706b\u5899\u5141\u8bb8 Samba \u80fd\u6c38\u4e45\u8bbf\u95ee\u7f51\u7edc\u3002<\/p>\n

\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u6267\u884c\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n

firewall-cmd --add-service=samba --permanent<\/pre>\n

\u6216\u8005\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 firewall-config \u5de5\u5177\u4ee5\u56fe\u5f62\u5316\u65b9\u5f0f\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n

\"\"<\/p>\n

6\u3001\u4ece Windows \u8bbf\u95ee Samba<\/strong><\/span><\/div>\n

\u5728 Windows \u4e2d\uff0c\u6253\u5f00\u6587\u4ef6\u8d44\u6e90\u7ba1\u7406\u5668\u3002\u5728\u5730\u5740\u680f\u4e2d\uff0c\u952e\u5165\u4e24\u4e2a\u53cd\u659c\u6760(\\\\)\uff0c\u7d27\u8ddf\u4f60\u7684 Linux \u673a\u5668\u7684\u5730\u5740(IP \u5730\u5740\u6216\u4e3b\u673a\u540d)\uff1a<\/p>\n

\"\"<\/p>\n

\u7cfb\u7edf\u5c06\u63d0\u793a\u4f60\u8f93\u5165\u767b\u5f55\u4fe1\u606f\u3002\u8f93\u5165\u7b2c 3 \u6b65\u4e2d\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u7ec4\u5408\u3002\u4f60\u73b0\u5728\u5e94\u8be5\u53ef\u4ee5\u8bbf\u95ee Linux \u673a\u5668\u4e0a\u7684\u4e3b\u76ee\u5f55\uff1a<\/p>\n

\"\"<\/p>\n

\u4ece Linux \u8bbf\u95ee Windows<\/strong><\/div>\n

\u4ee5\u4e0b\u6b65\u9aa4\u8bf4\u660e\u4e86\u5982\u4f55\u4ece Linux \u8bbf\u95ee\u5171\u4eab\u7684 Windows \u6587\u4ef6\u5939\u3002\u8981\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u9700\u8981\u4f60\u7684 Windows \u7528\u6237\u5e10\u6237\u5177\u6709\u7ba1\u7406\u5458\u6743\u9650\u3002<\/p>\n

1\u3001\u542f\u7528\u6587\u4ef6\u5171\u4eab<\/strong><\/span><\/div>\n

\u901a\u8fc7\u70b9\u51fb \u201cWindows \u6309\u94ae\u201d > \u201c\u8bbe\u7f6eSettings\u201d > \u201c\u7f51\u7edc\u548c InternetNetwork & Internet\u201d \uff0c\u6216\u8005\u53f3\u952e\u5355\u51fb\u4efb\u52a1\u680f\u53f3\u4e0b\u89d2\u7684\u5c0f\u76d1\u89c6\u5668\u56fe\u6807\uff0c\u6253\u5f00\u7f51\u7edc\u548c\u5171\u4eab\u4e2d\u5fc3Open Network an d Sharing Center\uff1a<\/p>\n

\u6253\u5f00\u7f51\u7edc\u548c\u5171\u4eab\u4e2d\u5fc3<\/p>\n

\u5728\u6253\u5f00\u7684\u7a97\u53e3\u4e2d\uff0c\u627e\u5230\u4f60\u8981\u4f7f\u7528\u7684\u8fde\u63a5\u5e76\u8bb0\u4e0b\u5176\u914d\u7f6e\u6587\u4ef6\u3002\u6211\u4f7f\u7528\u4e86 \u4ee5\u592a\u7f51 3\uff0c\u5b83\u88ab\u6807\u8bb0\u4e3a \u516c\u7528\u7f51\u7edcPublic Network\u3002<\/p>\n

\u6ce8\u610f\uff1a\u5982\u679c\u4f60\u7684 PC \u7ecf\u5e38\u8fde\u63a5\u516c\u7528\u7f51\u7edc\uff0c\u8bf7\u8003\u8651\u5c06\u672c\u5730\u8ba1\u7b97\u673a\u7684\u8fde\u63a5\u914d\u7f6e\u6587\u4ef6\u66f4\u6539\u4e3a \u79c1\u6709\u3002<\/p>\n

\u8bb0\u4f4f\u4f60\u7684\u7f51\u7edc\u914d\u7f6e\uff0c\u7136\u540e\u5355\u51fb \u66f4\u6539\u9ad8\u7ea7\u5171\u4eab\u8bbe\u7f6eChange advanced sharing settings\uff1a<\/p>\n

\"\"<\/p>\n

\u66f4\u6539\u9ad8\u7ea7\u5171\u4eab\u8bbe\u7f6e<\/p>\n

\u9009\u62e9\u4e0e\u4f60\u7684\u8fde\u63a5\u5bf9\u5e94\u7684\u914d\u7f6e\u6587\u4ef6\u5e76\u6253\u5f00 \u7f51\u7edc\u53d1\u73b0network discovery \u548c \u6587\u4ef6\u548c\u6253\u5370\u673a\u5171\u4eabfile and printer sharing\uff1a<\/p>\n

\"\"<\/p>\n

\u7f51\u7edc\u5171\u4eab\u8bbe\u7f6e<\/p>\n

2\u3001\u5b9a\u4e49\u4e00\u4e2a\u5171\u4eab\u6587\u4ef6\u5939<\/strong><\/span><\/div>\n

\u901a\u8fc7\u53f3\u952e\u5355\u51fb\u4f60\u8981\u5171\u4eab\u7684\u6587\u4ef6\u5939\u6253\u5f00\u4e0a\u4e0b\u6587\u83dc\u5355\uff0c\u5bfc\u822a\u5230 \u6388\u4e88\u8bbf\u95ee\u6743\u9650Give access to\uff0c\u7136\u540e\u9009\u62e9 \u7279\u5b9a\u7528\u6237...Specific people...\uff1a<\/p>\n

\"\"<\/p>\n

\u6388\u4e88\u8bbf\u95ee\u6743\u9650<\/p>\n

\u68c0\u67e5\u4f60\u5f53\u524d\u7684\u7528\u6237\u540d\u662f\u5426\u5728\u5217\u8868\u4e2d\u3002\u70b9\u51fb \u5171\u4eabShare \u5c06\u6b64\u6587\u4ef6\u5939\u6807\u8bb0\u4e3a\u5171\u4eab\uff1a<\/p>\n

\"\"<\/p>\n

\u6807\u8bb0\u4e3a\u5171\u4eab<\/p>\n

\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u6587\u4ef6\u8d44\u6e90\u7ba1\u7406\u5668\u7684\u5730\u5740\u680f\u4e2d\u8f93\u5165 \\\\localhost \u6765\u663e\u793a\u6240\u6709\u5171\u4eab\u6587\u4ef6\u5939\u7684\u5217\u8868\uff1a<\/p>\n

\"\"<\/p>\n

\u5171\u4eab\u6587\u4ef6\u5939<\/p>\n

\"\"<\/p>\n

\u5171\u4eab\u6587\u4ef6\u5939<\/p>\n

3\u3001\u5728 Linux \u4e0b\u6302\u8f7d\u5171\u4eab\u6587\u4ef6\u5939<\/strong><\/span><\/div>\n

\u56de\u5230\u4f60\u7684 Linux \u7cfb\u7edf\uff0c\u6253\u5f00\u4e00\u4e2a\u547d\u4ee4\u884c\uff0c\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\u5939\uff0c\u7528\u4e8e\u6302\u8f7d Windows \u5171\u4eab\uff1a<\/p>\n

mkdir ~\/WindowsShare<\/pre>\n

\u6302\u8f7d Windows \u5171\u4eab\u662f\u4f7f\u7528 mount.cifs \u5b8c\u6210\u7684\uff0c\u5b83\u5e94\u8be5\u88ab\u9ed8\u8ba4\u5b89\u88c5\u3002\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u4e34\u65f6\u6302\u8f7d\u4f60\u7684\u5171\u4eab\u6587\u4ef6\u5939\uff1a<\/p>\n

sudo mount.cifs \/\/<address-of-windows-pc>\/MySharedFolder ~\/WindowsShare\/ -o user=<Windows-user>,uid=$UID\r\n<\/pre>\n

\u5728\u8fd9\u4e2a\u547d\u4ee4\u91cc\uff1a
\n<address-of-windows-pc>\u662f Windows PC \u7684\u5730\u5740\u4fe1\u606f(IP \u6216\u4e3b\u673a\u540d)
\n<Windows-user>\u662f\u5141\u8bb8\u8bbf\u95ee\u5171\u4eab\u6587\u4ef6\u5939\u7684\u7528\u6237(\u89c1\u6b65\u9aa4 2)
\n\u7cfb\u7edf\u5c06\u63d0\u793a\u4f60\u8f93\u5165 Windows \u5bc6\u7801\u3002\u4e4b\u540e\uff0c\u4f60\u5c06\u80fd\u591f\u4f7f\u7528\u666e\u901a Linux \u7528\u6237\u8bbf\u95ee Windows \u4e0a\u7684\u5171\u4eab\u6587\u4ef6\u5939\u3002<\/p>\n

\u8981\u5378\u8f7d\u5171\u4eab\u6587\u4ef6\u5939\uff1a<\/p>\n

sudo umount ~\/WindowsShare\/<\/pre>\n

\u4f60\u8fd8\u53ef\u4ee5\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u6302\u8f7d Windows \u5171\u4eab\u6587\u4ef6\u5939\u3002\u6309\u7167 \u8fd9\u4e9b\u6b65\u9aa4 \u76f8\u5e94\u5730\u914d\u7f6e\u4f60\u7684\u7cfb\u7edf\u3002<\/p>\n

\u603b\u7ed3<\/strong><\/div>\n

\u5728\u8fd9\u91cc\u5c55\u793a\u4e86\u5982\u4f55\u5efa\u7acb\u4e34\u65f6\u7684\u6587\u4ef6\u5939\u5171\u4eab\u8bbf\u95ee\u6743\u9650\uff0c\u6bcf\u6b21\u91cd\u542f\u540e\u90fd\u8981\u91cd\u65b0\u8bbe\u7f6e\uff0c\u56e0\u6b64\u4fee\u6539\u6210\u6c38\u4e45\u8bbf\u95ee\u4f1a\u66f4\u4fbf\u5229\u3002\u6211\u7ecf\u5e38\u5728\u4e0d\u540c\u7684\u7cfb\u7edf\u4e4b\u95f4\u6765\u56de\u5207\u6362\uff0c\u5bf9\u6211\u800c\u8a00\u8bbe\u7f6e\u76f4\u63a5\u6587\u4ef6\u8bbf\u95ee\u975e\u5e38\u5b9e\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Samba \u662f SMB\/CIFS \u534f\u8bae\u7684 Linux \u5b9e\u73b0\uff0c\u5141\u8bb8\u901a\u8fc7\u7f51\u7edc\u8fde\u63a5\u76f4\u63a5\u8bbf\u95ee\u5171\u4eab\u7684\u6587\u4ef6\u5939\u548c\u6253\u5370\u673a\u3002 m […]<\/p>\n","protected":false},"author":323,"featured_media":58613,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-241949","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241949","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=241949"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241949\/revisions"}],"predecessor-version":[{"id":241976,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241949\/revisions\/241976"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/58613"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=241949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=241949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=241949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}