Julien Liabeuf

Setup Ubuntu Server with SFTP

April 12, 2014 | 3 Minute Read | 4 Comments

This article is the first one of a series about how to setup a cloud server server running Ubuntu 12.04. This server will be used to run multiple sites. Essentially Ghost blogs and WordPress sites.

Why DigitalOcean

Beforehand, just a few words about why I chose DigitalOcean:

  • Their service seems high level,
  • All plans include SSD,
  • Very aggressive pricing,
  • The interface is dead simple,
  • You really are up and running in less than a minute

Create a Droplet

The first thing to do is to create a Droplet. Their process is really well done and very clear.

As I want to be able to host multiple sites on this droplet, I didn't go with an Application image, but with a classic Ubuntu 12.04 x64 instead.

Their "55 seconds setup" is really not a lie. You really have your droplet up and running in less than a minute. It' pretty impressive.

Setup SFTP

I've heard so many times that FTP is a very insecure protocol that I didn't want to take any risk on this instance. I wanted to go with SFTP from the beginning and started to dig for tutorials on how to install ProFTPd with SFTP enabled.

After spending some time trying, I finally came across a very interesting post which basically said: no need for ProFTPd. As long as you can SSH into the server, you can SFTP as well.

I kept searching in that direction and here is what I came up with: create my users in Ubuntu, set their home directory, add them to a group, give the group the right permissions and that's it!

Create a Web Directory

First of all, let's create the directory. We will simply usr /var/www here. Try:

cd /var/www

If you get an error message saying the directory doesn't exist, create it by typing

mkdir /var/www

Our web directory is now ready.

Add Users

It's now time to add the desired users. For whatever reason I was not able to create a user and assign it a group at the same time. I had to do it in 2 steps.

sudo adduser newuser
usermod -a -G www-data newuser

Now that the user was created, you can possibly give him root privileges if this user is an admin. See "How to Grant a User Root Privileges" in this tutorial.

Last step for user creation is to change their home directory. The user's home directory is where he will land when reaching the server through SFTP.

sudo usermod -d /var/www/ username


Set the Permissons

That's a pretty big part we have done so far. What you are now able to do is to connect to your server via SFTP, and land into the www directory. However, you will not be able to do anything here as you won't have permissions. We're going to fix this now.

sudo chgrp -R www-data /var/www/*
sudo chmod -R g+rw /var/www
sudo chown -R username:username /var/www/*
find /var/www -type d -print0 | sudo xargs -0 chmod g+s


Here we are. You now have a cloud server that you can access via SFTP! Just open your FTP client and reach sftp://yourip on port 22 using the username and password you setup earlier.


Julien, Great tutorial! I have been looking for a solution like this all over the place. I wonder if you have previously used importbuddy.php before and have any solution for this:

“Error #224834. This directory, /var/www/funnl/, is not write enabled according to the server. Please verify proper write permissions to continue”

Your help will be appreciated and again, awesome and really helpful tutorial.

Thanks Esa.

Unfortunately I haven’t been using importbuddy.php. With the error you get, I would first check the CHMOD for /var/www/funnl/ (try 777), and alternatively set the permissions specifically for this directory (step “Set the Permissons”).

Appreciate the article, unfortunately (at least in my experience on Ubuntu 14.04), the user has access to everything outside of their directory as well.

[…] https://julienliabeuf.com/setup-cloud-server-sftp/ […]

Leave a Comment