Skip to content

Instantly share code, notes, and snippets.

@bigfleet
Created September 13, 2019 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigfleet/5d83fe2df70c6d63eba1d5a5be2e62f9 to your computer and use it in GitHub Desktop.
Save bigfleet/5d83fe2df70c6d63eba1d5a5be2e62f9 to your computer and use it in GitHub Desktop.
FTPS Setup for RHEL

Objective

Expose FTPS on a RHEL system to a z/OS mainframe client

Walkthrough

Install packages

yum install -y lftp openssl vsftpd

Set up SSL certificates

sudo mkdir /etc/ssl/private
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem

This will result in the certificate and the key being in the same file. Just alert your z/OS recepient that your file might not be copy/paste. That was all it took in my use case.

Examine vsFTPd config

Change defaults

anonymous_enable=NO
local_enable=NO
write_enable=NO

SSL Setup

ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES

rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem

Ciphers

ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
ssl_ciphers=HIGH

In our use case, we had some discussion about ciphers, but ultimately, HIGH was fine.

Support z/OS

From the RedHat Knowledge Base

ssl_request_cert=no
require_ssl_reuse=no

Bump up logging

xferlog_enable=YES
xferlog_std_format=NO
log_ftp_protocol=YES
xferlog_enable=YES

This will create a /var/log/vsftpd.log file to support troubleshooting the remote connection (as is quite likely).

Ensure IPv4/v6 squared away

listen=YES
listen_ipv6=NO
listen_address=0.0.0.0

Limit access

userlist_enable=YES
userlist_deny=NO

This combination limits incoming ftp access to a list of users that you explicitly allow within /etc/vsftpd/user_list. You can review the contents of that file for more information.

User setup

There is a much simpler setup available for you if you are on VSFTPD 3.

In our use case, we were on RedHat 6.10, which had VSFTPD 2.2. With version 3, you can use a local user approach, which we will outline below. With version 2.2, you need to use virtual users, which is an entirely seperate process.

Virtual Users

This clipping of a RedHat support article walks through this process.

The fundamental idea includes four components:

  1. A virtftp local user
  2. A root directory to contain files (e.g. /home/ftp but it's operator taste where to mount it)
  3. An authentication scheme that creates a directory of 'virtual' usernames and passwords that vsftpd (and pam.d) can auth against
  4. A per-user configuration file that provides user-specific configuration sufficient to authorize FTP activities.

Local Users

You should be aware of this security bulletin regarding the dangers of adding "bad" shells to /etc/shells

vsftpd config
chroot_local_user=YES
allow_writeable_chroot=YES

In particular the last setting is only available in vsftpd 3.

Testing your work

The lftp client that you installed in a previous section can be configured with a file containing these commands to help you.

set ftps:initial-prot "";
set ftp:ssl-force true;
set ftp:ssl-protect-data true;
set ssl:verify-certificate no;
set dns:order "inet inet6";

With this file stored in /tmp/lftp-test.commands, start an lftp process and provide this at the prompt:

source /tmp/lftp-test.commands
open -u ftpuser,whatever-password-you-picked ftps://127.0.0.1:21/

Roadblocks

Not sending version number

In our use case, this had to do with including implicit_ssl in the vsftpd config. When this was removed, the connection proceeded.

Client breaks off certs

The client needs the certificate, since it's self-signed and not a part of the trust chain. Getting to this roadblock before you circulate the certificate is fine.

Directory listing not sent

In our use case, this was because neither the client nor the server was originally set up to use the ports set aside at the firewall layer for PASV mode connections.

Other Takeaways

  • After checking out your setup from the server itself via 127.0.0.1, check your setup from another machine. You will find other items.

TODO

  • SELinux output:

Appendix A: Links

TCPDump resources

Appendix B: Conf file text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment