What you asked for...
What you are looking for is chroot
. This will set the /
root of the filesystem to a location of your choice.
If you chroot
to /home/bob
for the user bob
this location will look like /
for bob
. He will not see the rest of the filesystem. Because of this you want to place any programs he needs to run below this folder.
As we now know of chroot
we can then find plenty of answers and guides:
What you want...
If the database is accessible from the Debian machine and that is all what is needed then you are looking for a SSH tunnel. You still need to have a user account but this can be locked totally down. The important SSH settings are:
AllowTcpForwarding yes
- we are allowed to have a tunnel
ForceCommand /bin/false
- if you try to log in via ssh you will not get a shell
ChrootDirectory /opt/dummy_location/%u
- If you somehow get a shell anyway we have limited view of the filesystem to an empty location
With this knowledge we can again find plenty of prior art:
The above handles the ssh connection. If the user has physical access to the server then remember to set the shell for the user as well:
usermod -s /bin/false userbob
With the above in order then you can search around to see how to connect with any database client. As all the magic with SSH happens on the network layer this can work for all clients! When the tunnel is up it looks like the database is running on the local machine.
Some clients are aware of SSH tunnels and make your life a little easier. A common client would be HeidiSQL - see How to connect to a MySQL database over a SSH tunnel with HeidiSQL.
If you go the tunnel route then please please please test with a regular account first to make sure it works before you start to lock down the tunnel user!
And finally you should be using SSH keys instead of passwords. But this combined with the complexity of chroot is best left as the last thing to implement.
/home
directory by removingrx
for other. And creating a new group, etc. No need to apply recursively. – ctrl-alt-delor May 01 '20 at 21:20