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.
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.
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.
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.
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.
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.