Restart ProFTPd and test your connexion

/etc/init.d/proftpd restartsftp -P 2222 virtual1@localhost

Method 2: SFTP with ProFTPd (key auth)

Using private/public key brings a much stronger authentication, moreover if you use a passphrase. I will assume that you already have your keys (else: man ssh-keygen). The procedure remains close to the previous one:

Into /etc/proftpd/proftpd.conf

The SFTP configuration is the same as previous method. But there is a change in the section # Auth methods:

Now we will create a system user. That's where ProFTPD documentation lacks, they don't explain that you need this, nor why. So if we need this physical user it's because there are several points that ProFTPd can't define with "key" users :

the system rights for the virtual user (classic)

his shell (else he can't interact with the filesystem)

his (chrooted) home (the most important point !!)

So let's create the user virtual2 in the operating system. His home will be chrooted. I suggest you create it with a UID > 5000, in order to easily find these SFTP users in /etc/passwd :

adduser --home /var/www/mangento/dir --uid 5000 virtual2

Now, create the user in ProFTPd. Be carefull, ProFTPd will check the virtual user info with the system user. So their name MUST be exactly the same:

touch /etc/proftpd/sftp.passwd.keys/virtual2

Now fill the file with the SSH public keys you want. You need to convert it in RFC4716 style before:

Restart ProFTPd and test your connexion

/etc/init.d/proftpd restartsftp -P 2222 virtual2@localhost

Note: proftpd reload is used to crash proftpd. You need to start it then. Therefore restart solution is cleaner.

SFTP and FTP with ProFTPd

If you want to have both FTP and SFTP methods at the same time in ProFTPd, you will need to use a virtual host. First, define your FTP configuration as normally. Then put the whole SFTP configuration into the virtualhost, this way: