Skip to content

Instantly share code, notes, and snippets.

@cookie-ag
Last active October 5, 2016 06:03
Show Gist options
  • Save cookie-ag/f880799d460a658e75c371ea17a23a50 to your computer and use it in GitHub Desktop.
Save cookie-ag/f880799d460a658e75c371ea17a23a50 to your computer and use it in GitHub Desktop.
Creating a safe user in Ubuntu 16.04
// If the application has a error it can bring down the complete server as it has credentials to do so.
// To prevent this : Create a new user in /home/safeuser/
- if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi (Check if you are root)
- sudo -i (change to root)
- cut -d: -f1 /etc/passwd (To list all local users)
- useradd -s /bin/bash -m -d /home/safeuser -c "safe user" safeuser :(Create only as root)
- passwd safeuser : (Add a password)
- usermod -aG sudo safeuser :(Give safeuser permission to use root level commands)
- Login as safeUser : ssh safeuser@IP
- chmod 0444 /path/to/folder (Give any folder read-only access, such as SSL folder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment