Categories
Technology

Www-data SFTP User Setup

If you have followed our article Install WordPress on NGINX with FastCGI Cache in Ubuntu, you may noticed that when you try to login to FTP with default root or root privileged user, there are numbers of permission issue. Since we have assigned a www-data user for nginx, php5-fpm and the directory where we hosted all our web files, we need to assign the same user for FTP uses as well. So in this article I will guide you how to setup a www-data sftp user which will allows transfer to and from server. This Tutorial Explain www-data SFTP configuration.

SFTP

1. User Setup

To access the server first step is to setup authenticate user. So lets set a password for www-data user.

sudo passwd www-data

You will be asked for entering a password for www-data user 2 times. Assign a strong one.

2. Setup Login Shell

Check Login shell for the user using…

grep www-data /etc/passwd

…in output you will see…

www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin

By default it is set to nologin as you can see in the output; so we need to change it to a login shell and we will do this by changing /usr/sbin/nologin to /bin/bash for www-data user from /etc/password file.

nano /etc/passwd

…and modify it to a login shell…

www-data:x:33:33:www-data:/var/www:/bin/bash

Now you have a working sftp user

3. Test SFTP User

SSH Test

ssh [email protected]

FileZilla / CyberDuck / Transmit

Host: sftp://Server-IP-Address
User: www-data
Pass: Your-Password
Port: 22

Now you can transfer files to server without any issue.

By AtulHost

Hi, I'm Atul Kumar Pandey; also known as AtulHost on the web, a full-time blogger by profession with an objective of sharing fresh and honest contents in business and technology niche.