Wednesday 31 May 2023

Create user Ubuntu with the command and directory restriction

 Create User:

    sudo useradd -m user_name -s /bin/rbash

    sudo passwd user_name

    Enter password


Make Directory and grant permission  

    sudo mkdir /home/user_name/bin

    sudo chown root. /home/user_name/.profile

    sudo chmod 755 /home/user_name/.profile


Restrict Directory and access


sudo vim /home/user_name/.profile


################ADD BELOW IN FILE#######

# if running bash

if [ -n "$BASH_VERSION" ]; then

    # include .bashrc if it exists

    if [ -f "$HOME/.bashrc" ]; then

. "$HOME/.bashrc"

    fi

fi


# set PATH so it includes user's private bin if it exists

PATH=$HOME/bin


export PATH

#########################################


Assign Commands

sudo ln -s /bin/grep /home/user_name/bin/tail

sudo ln -s /bin/cat /home/user_name/bin/cat

sudo ln -s /bin/echo /home/user_name/bin/more

Create SFTP user with home directory restriction

 



Restrict on the home directory and sftp only Ubuntu

create a group -
 
sudo addgroup group_name

create a user

useradd -m -d /home/username username

Assign group to user

usermod -g group_name username


restrict the directory and ftp

add below to the end of /etc/ssh/sshd_config file

   Match Group group_name
   ChrootDirectory /home/username
   ForceCommand internal-sftp
   X11Forwarding no
   AllowTcpForwarding no


Still unable to log in to sftp try to change the ownership to root for the user's home directory. 

Also check the mod of the home directory, it should be 755

Enable 'HTML Manager'- Apache Tomcat

 Enable 'HTML Manager'- Apache Tomcat Go to Apache-tomcat's home directory and edit the tomcat-users.xml ${apache_home}/conf/tom...