I've set up mod_sftp with ProFTPD, and for some reason it still prompts me for a password when I connect.
This is my conf.d/myserver
file:
SFTPEngine on
SFTPLog /var/log/sftp.log
Port 7770
SFTPHostKey /etc/ssh/ssh_host_rsa_key
SFTPHostKey /etc/ssh/ssh_host_dsa_key
SFTPAuthorizedUserKeys file:/etc/proftpd/authorized_keys/%u
SFTPCompression delayed
MaxLoginAttempts 6
DefaultRoot ~
Umask 002
CreateHome on 770 dirmode 770
And the public key for the user is in /etc/proftpd/authorized_keys
.
I experienced this, and it was caused by what looks like a bug in
ssh-keygen
that manifests when you convert the ssh-rsa format key into the RFC-4716 key format: the Comment header is too long.To confirm that this is happening to you, enable the SFTPLog option in your
proftpd.conf
file, then in the SFTP log file you'll see lines like the following, specifically the "line too long" part:Take a look at the offending key, and you'll see how it sticks out:
Trim that off with your text editor of choice, and key auth should start working. Using bash it looks like this, where user.pub is your key file:
If you instead want to keep the whole comment, you'll need to escape the end of the line and put it on the next one. See the example section of RFC 4716 for how you can re-format comments.
Finally, I ran into this problem using
ssh-keygen
on CentOS 6.9. The version I have on Mac OS Sierra truncates the key comments properly to avoid this problem.The current value of SFTPAuthorizedUserKeys is set to use per-user files of authorized keys. I would guess that for a given user, let's use jsmith as an example, their key would need to go into a file called /etc/proftpd/authorized_keys/jsmith.
To get your current setup working try changing the value of SFTPAuthorizedUserKeys to /etc/proftpd/authorized_keys.
See http://www.proftpd.org/docs/contrib/mod_sftp.html#SFTPAuthorizedUserKeys for more detail.