Skip to content

Instantly share code, notes, and snippets.

@ntmggr
Last active March 19, 2017 22:35
Show Gist options
  • Save ntmggr/f33fa2e46541cf63d8f6cb1eea6f73d1 to your computer and use it in GitHub Desktop.
Save ntmggr/f33fa2e46541cf63d8f6cb1eea6f73d1 to your computer and use it in GitHub Desktop.

Redhat 6 - Restricted Korn Shell

Restricted Korn Shell

Assuming that ksh is installed. If not yum install ksh Create the link

ln -sf /bin/ksh93 /bin/rksh

Make the login shell of the user point to /bin/rksh i.e.

usermod -s /bin/rksh username

The user will not have now access to

  • Change the current working directory
  • Set the value of the SHELL, ENV, or PATH variables
  • Specify the pathname of a command containing a / (slash)
  • Redirect output of a command with > (right caret), >| (right caret, pipe symbol), <> (left caret, right caret), or >> (two right carets).

Avoid vi and awk and lang hacking and remove ls

Edit /etc/kshrc and append at the end of the file the following

if [ “$0” = “-rksh” ]
 then
   alias awk=''
   alias ls=''
   alias python=''
   alias perl=''
   alias vi='rvim'
   alias vim='rvim'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment