Setup Ubuntu Server with SFTP
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:
If you get an error message saying the directory doesn't exist, create it by typing
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.
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.
Sources
- https://www.digitalocean.com/community/articles/how-to-add-and-delete-users-on-ubuntu-12-04-and-centos-6
- http://www.cyberciti.biz/faq/ubuntu-add-user-to-group/
- http://ubuntuforums.org/showthread.php?t=1449220
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.
Source
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.
4 Comments
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/ […]