Suggestion for SFTP security

When using the proftpd SFTP engine with the virtualmin default settings you get an F on sshaudit.com

if you add these lines to /etc/proftpd/conf.d/virtualmin.conf you get an A+.

Somewhere below the

<VirtualHost 0.0.0.0>
  SFTPEngine on

section.

  SFTPHostKeys ssh-ed25519 rsa-sha2-512 rsa-sha2-256
  SFTPKeyExchanges curve25519-sha256 diffie-hellman-group18-sha512 diffie-hellman-group16-sha512
  SFTPCiphers aes128-ctr aes192-ctr aes256-ctr aes128-gcm@openssh.com aes256-gcm@openssh.com
  SFTPDigests hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com umac-128-etm@openssh.com

This is what I used on almalinux 9.3

Maybe it would be good practice to have this by default in the config or not? I know people may use sftp from openssh directly and not proftpd or even not use proftpd at all or no sftp and use the browser file manager in virtualmin (which is excellent) but for those who do, I think it might be a reasonable way to improve security standards.

2 Likes

Wow, great advise, just added to mine and works. (Rocky9)

You should mention your OS and version. The defaults for ProFTPd are different across distros and versions.

We historically don’t alter this (I’ve never logged in via FTP except to test that it works, so I have never paid attention to whether it’s good or not), but we could make the defaults safer by default.

It might also be advisable to remove ecdh nistp256 etc… from openssh main ssh. It has instructions for various distros. But this might be out of scope for a virtualmin install.

SSH Hardening Guides (sshaudit.com)

We try to do as little as possible, and respect the users OS choice. I feel like the OS vendor is responsible for ssh defaults, and the user is responsible for understanding a little bit about their system. And, ssh is necessary for access to the system, so we probably shouldn’t fiddle with it.

But, ProFTPd is pretty lightly maintained even in the distros that have it in the standard repos, and we have to modify its configuration for anything to work, so we probably should be a bit more proactive about it.

ok I added alma 9.3 reference

I dont recall if the sftp engine is enabled by default, might check with a fresh install these days, for other rpm and also deb based distro.

Also something to keep in mind, I think it is not monitored by fail2ban. I set it to be in the LAN subnet only.

1 Like

Breaks my (unused) Debian 11 proFTP.

Thanks for this! I’m also running Alma 9.3 & implemented your suggestion. Then I ran it on my SSH port and was able to harden that a bit by following its recommendations. Much appreciated.

I wouldn’t mind either making defaults safer!

Did anyone come up with “safer entries” for Debian 11 ???

Not sure what is going on with Debian 11.

It kindly asks if maybe I mean SFTPHostKey even though this is shown as a valid entry on the Proftpd site. I played with it a bit, but, since I leave ftp turned off, my futility didn’t need much more of a workout yesterday.

That would be the path to the key. For example:

  # Configure the RSA and ECDSA host keys, using the same host key
  # files that OpenSSH uses.
  #SFTPHostKey /etc/proftpd/ssh_host_ecdsa_key
  SFTPHostKey /etc/proftpd/ssh_host_ed25519_key
  SFTPHostKey /etc/proftpd/ssh_host_rsa_key

I think these are two separate things. One is the keys used by the server, the other is key types accepted for use. I’d get errors telling me it didn’t have permission to parse the file and then complain about the items in it. At this point it is a personal server and I just use OpenSSH SFTP. That is covered with the recommendations here.
www.sshaudit.com/hardening_guides.html#debian_11

Strangely I tried to mimic the settings for proFTP but they didn’t work as I said above.

Yes.

Anyway. There are some methods that are just weaker considering todays computing power. But even most of those would be beyond a lifetime to decode.

Screenshot 2024-04-18 215202

I mean this is from the 90s. Most likely just legitimate research on cryptography.

But just saying that apart from some funny story from the guy himself (he passed away unfortunately :frowning: , there is no official specification on the seed value for p256 from the national institute of standards and technology.

But we do know that a NSA employee supplied it.

Hence some scepticism. BUT really no proof of anything.

SafeCurves: Rigidity (yp.to)

With or without tinfoil hats, server hardening should be fun :slight_smile:

To get these “ssh audit hardening guide” commands to upgrade you from F to A on ubuntu 22.04, in addition to running the commands given in the hardening guide for ubuntu 22.04, you also have to add this line at the top of your /etc/ssh/sshd_config file:
Include /etc/ssh/sshd_config.d/*.conf
To get an A+ ,you have to edit:
sudo nano /etc/ssh/sshd_config.d/ssh-audit_hardening.conf
remove from the Ciphers list: chacha20-poly1305@openssh.com,
save the file (ctrl-o enter), and exit (ctrl x).
Restart sshd service: sudo service sshd restart
And run the ssh audit web test again. You’ll see A+ grade.

For extra + points :stuck_out_tongue:

However, ChaCha20-Poly1305 itself was not the issue, it was the SSH implementation of it.

Wireguard for example uses ChaCha20-Poly1305 as well.

It has speed advantages.

You can test if you are vulnerable with this tool for example:

RUB-NDS/Terrapin-Scanner: This repository contains a simple vulnerability scanner for the Terrapin attack present in the paper “Terrapin Attack: Breaking SSH Channel Integrity By Sequence Number Manipulation”. (github.com)

It is fine to use if you dont have cbc-etm in use.

Screenshot 2024-04-21 125944