{"id":839,"date":"2016-07-01T11:49:38","date_gmt":"2016-07-01T09:49:38","guid":{"rendered":"http:\/\/ndk.sytes.net\/wordpress\/?p=839"},"modified":"2016-07-01T11:49:38","modified_gmt":"2016-07-01T09:49:38","slug":"restricted-bash-on-centos","status":"publish","type":"post","link":"https:\/\/ndk.sytes.net\/wordpress\/?p=839","title":{"rendered":"Restricted BASH on CentOS"},"content":{"rendered":"<p>\n\tHow do put a user into a restricted bash environment? Let&#39;s say for example for using the shell access only for SSH tunneling? Here a small howto:\n<\/p>\n<p>\n\tFirst you need to create a symlink called &quot;rbash&quot; as it does not exist&nbsp;on CentOS\/Fedora. If bash is invoked as rbash it automatically transforms into a restricted shell\n<\/p>\n<pre>\n# ln -s \/bin\/bash \/bin\/rbash<\/pre>\n<p>\n\tnow open your passwd file and change the shell to rbash and save, your line should then look like the following:\n<\/p>\n<pre>\n&lt;USER&gt;:x:&lt;UID&gt;:&lt;GID&gt;::&lt;HOMEDIR&gt;:\/bin\/rbash<\/pre>\n<p>\n\tNext step is to harden the bash for that previously mentioned user so that he cannot execute any commands:\n<\/p>\n<p>\n\topen .bashrc in the user&#39;s homefolder and change the &quot;export PATH&quot; line:\n<\/p>\n<pre>\nexport PATH=~<\/pre>\n<p>\n\tthis sets the path to the home folder. Now secure the file against further changes:\n<\/p>\n<pre>\nchown root:&lt;myuser&gt; .bashrc\nchmod 640 .bashrc<\/pre>\n<p>\n\tThat&#39;s it. now test it and the logged in user should not be able to execute any commands. <a href=\"http:\/\/man.he.net\/man1\/rbash\" target=\"_blank\">More information about the restricted shell can be found here<\/a>.\n<\/p>\n<p>\n\tIf you want the user to execute specific commands use symlinks into his homefolder:\n<\/p>\n<pre>\n# ln -s \/bin\/ping \/home\/&lt;user&gt;\/ping<\/pre>\n<p>\n\tThis article\/howto is based on <a href=\"http:\/\/blog.bodhizazen.net\/linux\/how-to-restrict-access-with-rbash\/\" target=\"_blank\">this one<\/a>. Thanks for your&nbsp;work!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How do put a user into a restricted bash environment? Let&#39;s say for example for using the shell access only for SSH tunneling? Here a small howto: First you need to create a symlink called &quot;rbash&quot; as it does not exist&nbsp;on CentOS\/Fedora. If bash is invoked as rbash it automatically transforms into a restricted shell [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,7],"tags":[],"class_list":["post-839","post","type-post","status-publish","format-standard","hentry","category-linuxunix","category-servers"],"_links":{"self":[{"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=839"}],"version-history":[{"count":0,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/839\/revisions"}],"wp:attachment":[{"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ndk.sytes.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}