Setup a SFTP server on ubuntu under 1 minute

SFTP is a great choice to securely transfer file accross a network. The most ubiquitous SFTP server there is is openssh which we will be installing in this guide.

Basic setup

Assuming the machine you run your server from is running ubuntu, open up a terminal and type:

~/$ sudo apt install -y openssh-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
~/$ sudo service ssh start
* Starting OpenBSD Secure Shell server sshd                      [ OK ]

You’re done. By default this server will use the user / password setup in your machine.

Making it more fancy

By default this server will use the user / password setup in your machine so you can use standard tools to manage users like this:

~/$ sudo adduser test
Adding user `test' ...
Adding new group `test' (1000) ...
Adding new user `test' (1000) with group `test' ...
Creating home directory `/home/test' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for test
Enter the new value, or press ENTER for the default
    Full Name []:
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n]
Y
~/$ sudo deluser test
Removing user `test' ...
Warning: group `test' has no more members.
Done.

There’s tons of configuration options you can opt in from this server config file located under /etc/ssh/sshd_config. If you make some change, don’t forget to restart the server:

~/$ sudo service ssh restart
* Restarting OpenBSD Secure Shell server sshd                    [ OK ]