Ubuntu 14.04 - Allow Login As www-data User

Logging in as the apache user (www-data) is useful when trying to figure out permission denied errors. I always first check that I can access the files when I am logged in as that user. Unfortunately, with ubuntu 14.04, unlike 12.04, the www-data user is set to not allow login, so you need to run the command(s) below.

sudo sed -i 's;www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin;www-data:x:33:33:www-data:/var/www:/bin/bash;' /etc/passwd
sudo su
su www-data

5 comments:

  1. Hi

    How can I roll back the changes ?

    ReplyDelete
    Replies
    1. Just open the file
      /var/www:/bin/bash
      and change the line
      www-data:x:33:33:www-data:/var/www:/bin/bash;
      to
      www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin

      Delete
    2. I think the file should be /etc/passwd, not /var/www:/bin/bash :)

      Delete
    3. The file being edited is already /etc/passwd, the /var/www you see is the home directory of the www-data user.

      Delete