{"id":780,"date":"2023-12-19T09:56:25","date_gmt":"2023-12-19T09:56:25","guid":{"rendered":"http:\/\/192.168.50.210\/wordpress\/?p=780"},"modified":"2024-01-19T02:21:23","modified_gmt":"2024-01-19T02:21:23","slug":"rpi-nas-extras-adding-and-removing-users","status":"publish","type":"post","link":"https:\/\/mpr-projects.com\/index.php\/2023\/12\/19\/rpi-nas-extras-adding-and-removing-users\/","title":{"rendered":"RPi NAS: Extras \u2013 Adding and Removing Users"},"content":{"rendered":"\n<p>This is a brief post about adding and removing users to and from our NAS after the initial setup. There are lots of websites showing how to add a user to Samba. I just want to point out something that&#8217;s worth knowing when testing the setup of the new user.<\/p>\n\n\n<p>This post is part of a series about building a Network-Attached Storage (NAS) with redundancy using a Raspberry Pi (RPi). See <a href=\"https:\/\/mpr-projects.com\/index.php\/2023\/11\/13\/building-a-raspberry-pi-nas-with-data-redundancy-part-1-overview\/#RPi_NAS_Post_List\" data-type=\"post\" data-id=\"8\">here<\/a> for a list of all posts in this series.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" style=\"margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Adding a User <\/h2>\n\n\n\n<p>You can add a user with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo adduser --no-create-home --disabled-password --disabled-login username<\/code><\/pre>\n\n\n\n<p>You&#8217;ll be asked to enter some additional information (but you don&#8217;t have to). Then the new user will be created and added to group <em>users<\/em>. No home directory and password will be created and the user won&#8217;t be able to log in on the RPi (none of that is necessary for a user that should only be able to connect via Samba). Next we add the user to Samba and setup their password with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo smbpasswd -a username<\/code><\/pre>\n\n\n\n<p>Finally reboot your system for the changes to take effect (or log out and log back in).<\/p>\n\n\n\n<p>Now that we&#8217;ve added the user it seems normal (at least to me) to try to mount a Samba share on our main computer, using the newly created user. The following command (which we&#8217;ve been using to mount shares) fails:<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69d29cb4be231&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69d29cb4be231\" class=\"wp-block-image size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"38\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/mpr-projects.com\/wp-content\/uploads\/2023\/12\/Adding_Users_1-1024x38.png\" alt=\"\" class=\"wp-image-785\" srcset=\"https:\/\/mpr-projects.com\/wp-content\/uploads\/2023\/12\/Adding_Users_1-1024x38.png 1024w, https:\/\/mpr-projects.com\/wp-content\/uploads\/2023\/12\/Adding_Users_1-300x11.png 300w, https:\/\/mpr-projects.com\/wp-content\/uploads\/2023\/12\/Adding_Users_1-768x29.png 768w, https:\/\/mpr-projects.com\/wp-content\/uploads\/2023\/12\/Adding_Users_1-1536x57.png 1536w, https:\/\/mpr-projects.com\/wp-content\/uploads\/2023\/12\/Adding_Users_1-2048x76.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p>That&#8217;s because we set the <em>uid<\/em> option to <em>test_user<\/em>, which doesn&#8217;t exist on our main system. So to test mounting the share we either add <em>test_user<\/em> to our main system or we run the command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mount -t cifs \/\/192.168.50.210\/ShareName \/Mount\/Point -o user=test_user<\/code><\/pre>\n\n\n\n<p>which doesn&#8217;t contain the <em>uid<\/em> option. Leaving out <em>uid<\/em> means that we won&#8217;t be able to write to the Share but that shouldn&#8217;t be an issue if we only want to test if mounting works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Removing a User<\/h2>\n\n\n\n<p>To remove a user we first remove it from Samba with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo smbpasswd -x username<\/code><\/pre>\n\n\n\n<p>Then we delete it from the system with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo userdel username<\/code><\/pre>\n\n\n\n<p>Done.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a brief post about adding and removing users to and from our NAS after the initial setup. There are lots of websites showing how to add a user to Samba. I just want to point out something that&#8217;s worth knowing when testing the setup of the new user. Adding a User You can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"wp-custom-template-single-post-cc","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[3,10],"tags":[9,7,4,5],"class_list":["post-780","post","type-post","status-publish","format-standard","hentry","category-linux","category-projects","tag-data-safety","tag-greyhole","tag-linux","tag-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/posts\/780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/comments?post=780"}],"version-history":[{"count":15,"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/posts\/780\/revisions"}],"predecessor-version":[{"id":1437,"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/posts\/780\/revisions\/1437"}],"wp:attachment":[{"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/media?parent=780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/categories?post=780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mpr-projects.com\/index.php\/wp-json\/wp\/v2\/tags?post=780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}