#StackBounty: #linux #ssh #permissions #raspbian Cannot log in after changing permissions with owncloud script

Bounty: 50

I am trying to install owncloud and had some issues with permissions in /var/www/html/. One site suggested to run a script which changes the permission, and it looked ok to me so I ran it as root in the directory /home/owncloud.

ocpath='/home/owncloud'
htuser='www-data'
htgroup='www-data'
rootuser='root'

printf "Creating possible missing Directoriesn"
mkdir -p $ocpath/data
mkdir -p $ocpath/assets
mkdir -p $ocpath/updater

printf "chmod Files and Directoriesn"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750

printf "chown Directoriesn"
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/

chmod +x ${ocpath}/occ

printf "chmod/chown .htaccessn"
if [ -f ${ocpath}/.htaccess ]
 then
  chmod 0644 ${ocpath}/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
 then
  chmod 0644 ${ocpath}/data/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi

source

However, something must have gone terribly wrong, and I got plenty of errors in the style of chmod: changing permissions of 'xxx': Operation not permitted.

Now I can’t even log in any more using ssh:

ssh -p 1234 user@fakeraspi.ddns.net
user@fakeraspi.ddns.net's password: 
/bin/bash: Permission denied

Two questions: What could have possibly gone wrong? And less important: Is there a way to fix this (it’s a test server, so no harm if I have to restore from a backup).


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.