{"id":44952,"date":"2024-10-06T19:24:14","date_gmt":"2024-10-06T11:24:14","guid":{"rendered":"https:\/\/server.hk\/cnblog\/44952\/"},"modified":"2024-10-06T19:24:14","modified_gmt":"2024-10-06T11:24:14","slug":"linux-%e4%b8%8b%e4%bd%bf%e7%94%a8-samba-%e5%85%b7%e9%ab%94%e6%ad%a5%e9%a9%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/44952\/","title":{"rendered":"Linux \u4e0b\u4f7f\u7528 Samba \u5177\u9ad4\u6b65\u9a5f"},"content":{"rendered":"<h1 id=\"linux-%e4%b8%8b%e4%bd%bf%e7%94%a8-samba-%e5%85%b7%e9%ab%94%e6%ad%a5%e9%a9%9f-PGPrPWROAD\">Linux \u4e0b\u4f7f\u7528 Samba \u5177\u9ad4\u6b65\u9a5f<\/h1>\n<p>Samba \u662f\u4e00\u500b\u958b\u6e90\u8edf\u9ad4\uff0c\u5141\u8a31 Linux \u548c Windows \u7cfb\u7d71\u4e4b\u9593\u5171\u4eab\u6587\u4ef6\u548c\u6253\u5370\u6a5f\u3002\u5b83\u5be6\u73fe\u4e86 SMB\/CIFS \u5354\u8b70\uff0c\u4f7f\u5f97\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7d71\u4e4b\u9593\u7684\u4e92\u64cd\u4f5c\u6027\u8b8a\u5f97\u66f4\u52a0\u5bb9\u6613\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5728 Linux \u7cfb\u7d71\u4e0a\u5b89\u88dd\u548c\u914d\u7f6e Samba \u7684\u5177\u9ad4\u6b65\u9a5f\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-samba-PGPrPWROAD\">\u5b89\u88dd Samba<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728 Linux \u7cfb\u7d71\u4e0a\u5b89\u88dd Samba\u3002\u6839\u64da\u60a8\u4f7f\u7528\u7684\u767c\u884c\u7248\uff0c\u5b89\u88dd\u547d\u4ee4\u53ef\u80fd\u6703\u6709\u6240\u4e0d\u540c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684 Linux \u767c\u884c\u7248\u7684\u5b89\u88dd\u547d\u4ee4\uff1a<\/p>\n<ul>\n<li>\u5c0d\u65bc Ubuntu\/Debian \u7cfb\u7d71\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<pre><code>sudo apt update\nsudo apt install samba<\/code><\/pre>\n<li>\u5c0d\u65bc CentOS\/RHEL \u7cfb\u7d71\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<pre><code>sudo yum install samba samba-client samba-common<\/code><\/pre>\n<\/ul>\n<h2 id=\"%e9%85%8d%e7%bd%ae-samba-PGPrPWROAD\">\u914d\u7f6e Samba<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u914d\u7f6e Samba\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u7de8\u8f2f Samba \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u901a\u5e38\u4f4d\u65bc \/etc\/samba\/smb.conf\u3002\u4f7f\u7528\u60a8\u559c\u6b61\u7684\u6587\u672c\u7de8\u8f2f\u5668\u6253\u958b\u8a72\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/samba\/smb.conf<\/code><\/pre>\n<h3 id=\"%e8%a8%ad%e7%bd%ae%e5%85%b1%e4%ba%ab%e7%9b%ae%e9%8c%84-PGPrPWROAD\">\u8a2d\u7f6e\u5171\u4eab\u76ee\u9304<\/h3>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u60a8\u53ef\u4ee5\u6dfb\u52a0\u5171\u4eab\u76ee\u9304\u7684\u8a2d\u7f6e\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u793a\u4f8b\u914d\u7f6e\uff1a<\/p>\n<pre><code>[shared]\n   path = \/srv\/samba\/shared\n   browsable = yes\n   writable = yes\n   guest ok = yes\n   read only = no\n   force user = nobody<\/code><\/pre>\n<p>\u5728\u9019\u500b\u793a\u4f8b\u4e2d\uff0c\u6211\u5011\u5275\u5efa\u4e86\u4e00\u500b\u540d\u70ba &#8220;shared&#8221; \u7684\u5171\u4eab\u76ee\u9304\uff0c\u4e26\u8a2d\u7f6e\u4e86\u76f8\u95dc\u7684\u6b0a\u9650\u3002\u60a8\u53ef\u4ee5\u6839\u64da\u9700\u8981\u8abf\u6574\u9019\u4e9b\u8a2d\u7f6e\u3002<\/p>\n<h3 id=\"%e5%89%b5%e5%bb%ba%e5%85%b1%e4%ba%ab%e7%9b%ae%e9%8c%84-PGPrPWROAD\">\u5275\u5efa\u5171\u4eab\u76ee\u9304<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5275\u5efa\u5171\u4eab\u76ee\u9304\u4e26\u8a2d\u7f6e\u9069\u7576\u7684\u6b0a\u9650\uff1a<\/p>\n<pre><code>sudo mkdir -p \/srv\/samba\/shared\nsudo chown nobody:nogroup \/srv\/samba\/shared\nsudo chmod 0777 \/srv\/samba\/shared<\/code><\/pre>\n<h2 id=\"%e5%95%9f%e5%8b%95-samba-%e6%9c%8d%e5%8b%99-PGPrPWROAD\">\u555f\u52d5 Samba \u670d\u52d9<\/h2>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u555f\u52d5 Samba \u670d\u52d9\u4e26\u8a2d\u7f6e\u5176\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl start smbd\nsudo systemctl enable smbd<\/code><\/pre>\n<h2 id=\"%e9%98%b2%e7%81%ab%e7%89%86%e8%a8%ad%e7%bd%ae-PGPrPWROAD\">\u9632\u706b\u7246\u8a2d\u7f6e<\/h2>\n<p>\u5982\u679c\u60a8\u7684\u7cfb\u7d71\u555f\u7528\u4e86\u9632\u706b\u7246\uff0c\u60a8\u9700\u8981\u5141\u8a31 Samba \u7684\u6d41\u91cf\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728 UFW \u548c Firewalld \u4e2d\u8a2d\u7f6e\u9632\u706b\u7246\u7684\u793a\u4f8b\uff1a<\/p>\n<ul>\n<li>\u5c0d\u65bc UFW\uff1a<\/li>\n<pre><code>sudo ufw allow samba<\/code><\/pre>\n<li>\u5c0d\u65bc Firewalld\uff1a<\/li>\n<pre><code>sudo firewall-cmd --permanent --add-service=samba\nsudo firewall-cmd --reload<\/code><\/pre>\n<\/ul>\n<h2 id=\"%e6%b8%ac%e8%a9%a6-samba-%e5%85%b1%e4%ba%ab-PGPrPWROAD\">\u6e2c\u8a66 Samba \u5171\u4eab<\/h2>\n<p>\u6700\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6e2c\u8a66 Samba \u5171\u4eab\u662f\u5426\u6b63\u5e38\u904b\u884c\uff1a<\/p>\n<pre><code>smbclient -L localhost -U nobody<\/code><\/pre>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u80fd\u5920\u770b\u5230\u60a8\u525b\u525b\u5275\u5efa\u7684\u5171\u4eab\u76ee\u9304\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-PGPrPWROAD\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u5728 Linux \u7cfb\u7d71\u4e0a\u6210\u529f\u5b89\u88dd\u548c\u914d\u7f6e Samba\uff0c\u5be6\u73fe\u6587\u4ef6\u5171\u4eab\u529f\u80fd\u3002\u7121\u8ad6\u662f\u7528\u65bc\u5bb6\u5ead\u7db2\u7d61\u9084\u662f\u4f01\u696d\u74b0\u5883\uff0cSamba \u90fd\u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u670d\u52d9\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u4f86\u9032\u4e00\u6b65\u63d0\u5347\u60a8\u7684\u7db2\u7d61\u6027\u80fd\u548c\u5b89\u5168\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5728 Linux \u4e0b\u4f7f\u7528 Samba \u7684\u5177\u9ad4\u6b65\u9a5f\uff0c\u8f15\u9b06\u5171\u4eab\u6587\u4ef6\u548c\u6253\u5370\u6a5f\uff0c\u63d0\u5347\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-44952","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=44952"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44952\/revisions"}],"predecessor-version":[{"id":44953,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44952\/revisions\/44953"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=44952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=44952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=44952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}