{"id":39,"date":"2012-09-11T05:13:14","date_gmt":"2012-09-11T05:13:14","guid":{"rendered":"https:\/\/www.nicktailor.com\/?p=39"},"modified":"2022-10-21T11:59:55","modified_gmt":"2022-10-21T11:59:55","slug":"jail-secondary-ftpwebuser-accounts-with-plesk-via-sftp","status":"publish","type":"post","link":"https:\/\/nicktailor.com\/tech-blog\/jail-secondary-ftpwebuser-accounts-with-plesk-via-sftp\/","title":{"rendered":"Jail Secondary FTP\/Webuser Accounts with Plesk via SFTP"},"content":{"rendered":"<p><strong>How to Jail Secondary FTP\/Webuser Accounts with Plesk via SFTP<\/strong><\/p>\n<p>1.Log into Plesk and Create Secondary (&#8220;WebUser&#8221; inside plesk)user\/password (You need to do this so the client can update the password for the user from the GUI)<\/p>\n<p>2.Mkdir \/home\/newuseryoucreatedinplesk (since you created the user in plesk, the user homedirectory will need to manually created for jailing purposes)<br \/>\neg. Mkdir \/home\/superman<\/p>\n<p>3.? Next you want to do the following:<br \/>\n<em>-# usermod -G sftp superman<\/em> (add the user)<br \/>\n<em>-# usermod -s \/bin\/false superman<\/em> (change the bash of the user)<br \/>\n<em>-# chmod -R root:root \/home\/superman<\/em>\u00a0<strong>(parent directory has to be owned by root for chroot)<\/strong><br \/>\n-# <em>chmod 755 \/home\/superman<\/em> <strong>(Permissions on parent directory has to be 755 for sftp to work via chroot)<\/strong><\/p>\n<p>4. Edit \/etc\/passwd file and change the directory path of <strong>superman<\/strong> to <em>\/home\/superman<\/em> (You need to do this since plesk created the user, do not change the UID as this may be saved somewhere in plesk)<\/p>\n<p><em>eg. superman:x:10034:2522::\/home\/superman:\/bin\/false<\/em><\/p>\n<p>5. Now you are going to mount the directory that you wanted the user jailed into to the new users home directory<\/p>\n<p>#- Mount &#8211;bind &lt;fullpathofdirectoryyouwanttojailuser&gt; &lt;pathtonewusershomdirectory&gt;<br \/>\nEg.<br \/>\nMount &#8211;bind \/www_data\/test.com\/httpdocs\/jailed \/home\/superman\/jailed<\/p>\n<p><strong>Note:so I create this file give it +x permissions and add it to \/etc\/rc.local so that if the server reboots you don&#8217;t loose your mounts.<\/strong><br \/>\n6. Add the above line to \/etc\/init.d\/sftpjailedmounts.sh &lt;&#8211;this is so if you reboot the server the mounts arent lost, this file is loaded by \/etc\/rc.local<\/p>\n<p>7. Now your going to change the permissions inside their home directory so the sftp user will be able to ftp files<br \/>\n<em>#- chown superman:sftp \/home\/superman\/jailed<\/em><\/p>\n<p>8. Test and Ensure you can update the password from plesk admin panel for the client<\/p>\n<p>If you want to see your mount simply type mount and you will them.<br \/>\neg.<\/p>\n<p>[root@test]# mount<br \/>\n\/dev\/mapper\/VGroot-LVroot on \/ type ext3 (rw)<br \/>\nproc on \/proc type proc (rw)<br \/>\nsysfs on \/sys type sysfs (rw)<br \/>\ndevpts on \/dev\/pts type devpts (rw,gid=5,mode=620)<br \/>\n\/dev\/sda1 on \/boot type ext3 (rw)<br \/>\ntmpfs on \/dev\/shm type tmpfs (rw)<br \/>\n\/dev\/mapper\/VGroot-LVlocal on \/local type ext3 (rw)<br \/>\nnone on \/proc\/sys\/fs\/binfmt_misc type binfmt_misc (rw)<br \/>\nsunrpc on \/var\/lib\/nfs\/rpc_pipefs type rpc_pipefs (rw)<br \/>\nWEBI_NASdevl:\/vol\/WEBI_VerfConfig\/www_config on \/www_config type nfs (rw,addr=10.90.20.8)<br \/>\nWEBI_NASdevl:\/vol\/WEBI_VerfData\/www_data on \/www_data type nfs (rw,addr=10.90.20.8)<br \/>\ntmpfs on \/usr\/local\/psa\/handlers\/before-local type tmpfs (rw)<br \/>\ntmpfs on \/usr\/local\/psa\/handlers\/before-queue type tmpfs (rw)<br \/>\ntmpfs on \/usr\/local\/psa\/handlers\/before-remote type tmpfs (rw)<br \/>\ntmpfs on \/usr\/local\/psa\/handlers\/info type tmpfs (rw)<br \/>\ntmpfs on \/usr\/local\/psa\/handlers\/spool type tmpfs (rw,mode=0770,uid=2021,gid=31)<br \/>\n<em><strong>\/www_data\/test.com\/httpdocs\/jailed on \/home\/superman\/jailed type none<\/strong><\/em><strong> (rw,bind)<\/strong><strong>&lt;&#8212;&#8212;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Jail Secondary FTP\/Webuser Accounts with Plesk via SFTP 1.Log into Plesk and Create Secondary (&#8220;WebUser&#8221; inside plesk)user\/password (You need to do this so the client can update the password for the user from the GUI) 2.Mkdir \/home\/newuseryoucreatedinplesk (since you created the user in plesk, the user homedirectory will need to manually created for jailing purposes) eg. Mkdir \/home\/superman<a href=\"https:\/\/nicktailor.com\/tech-blog\/jail-secondary-ftpwebuser-accounts-with-plesk-via-sftp\/\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,138],"tags":[],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-centos","category-linux"],"_links":{"self":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":2,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":41,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/39\/revisions\/41"}],"wp:attachment":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}