This is a step by step guide to create a new user and restrict the user to his home directory.

1. Create a new user

 
sudo adduser TestUser

2. Change the ownership of TestUser’s home directory to root.

 
sudo chown root:root /home/TestUser

3. Edit the ssh config file

 
sudo vim /etc/ssh/sshd_config

and add the following lines to it:

 
Match user TestUser
ChrootDirectory /home/TestUser
AllowTcpForwarding no
ForceCommand internal-sftp

4. Restart SSH Service

 
sudo service ssh restart

Now, try logging in as the TestUser.

Hope it helps!

Tagged with:  

Leave a Reply

*

Search