php


Ubuntu - Prevent Linux/Apache users from listing anything but their home directory with PHP


Long story short, I'm in the early stages of building a small web hosting server. When I create a new site for a customer this happens:
A new Linux user is created with a home directory and /sbin/nologin
The user is added to group sftpusers
A public_html is created in the users home directory
A new Apache Vhost is created
The site is started and the process is running as the new Linux user using mpm-itk and AssignUserId
All well so far. The user can only sftp in to the home directory and put his files there. The user can't navigate outside the home directory when using a SFTP client like WinSCP or similar.
The problem is that they can list stuff outside the home dir with a bit of php. This will list everything in /etc/:
$scan = scandir(/etc);
foreach ($scan as $i) {
echo $i;
}
This is my problem and it needs to be dealt with, but I don't really know how.
My /etc/ssh/sshd_config:
Subsystem sftp internal-sftp
Match Group sftpusers
ChrootDirectory /home/%u
ForceCommand internal-sftp
AllowTCPForwarding no
X11Forwarding no
Please let me know if additional information is needed.
Solved this by using open_basedir

Related Links

How to use php select mysql field type of `blob`
PHP : get data from database
merge new json element as array in JSON
I did validation for my product insertion page but the product is not inserting into the database?
How can I get a list of followers from one instagram account?
PHP5 application is not working in PHP7 live server (ubuntu 16.04) -
Read Gmail inbox resulting in 'Too many login failures' error
Share variable between active php processes
Need to parse php array in ajax success callback
Specific fields only via Laravel Collection?
Creating An extension installer for a cms using laravel 5.3
Process SQL return into JSON
Restrict Google Geocoding to only true country results
apache Error in `/usr/sbin/apache2': free(): invalid next size (fast)
PHP can't unlink file after fclose
How to remove black border of Youtube image

Categories

HOME
bokeh
hdfs
whmcs
tabs
lvm
gentelella
turbojpeg
phpmqtt
wagtail
graphql-js
phpseclib
yahoo
siesta
multi-step
jqxgrid
boomi
infrared
node-webkit
sybase-ase
opentext
web-push
python-imageio
sendmessage
adapter
ninject
fatfs
nic
actframework
quickcheck
android-collapsingtoolbar
transform
sbjson
minikube
nomad
audio-converter
nothing
winston
visual-format-language
iptv
nivo-slider
stateless-session-bean
alertify
sidewaffle
hmmlearn
portal
libharu
mathjs
livecycle
xcode8-beta4
urbit
mnesia
gulp-uglify
ioctl
uitest
console.log
deque
mgwt
nsmutabledata
kognitio-wx2
visual-studio-6
forio-contour
jack
gpu-programming
typesafe-stack
pbkdf2
unrealscript
insertion
sunstudio
notin
asp.net-mvc-3-areas
donut-chart
oembed
examine
red-system
gprof
user-forums
lynx
gitx
affinetransform
aggregator
3-tier
activestate
html-components
main-method
code-camp

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App