Gleb Smirnoff ca573c9a17 sshd: update the libwrap patch to drop connections early
OpenSSH has dropped libwrap support in OpenSSH 6.7p in 2014
(f2719b7c in github.com/openssh/openssh-portable) and we
maintain the patch ourselves since 2016 (a0ee8cc636cd).

Over the years, the libwrap support has deteriotated and probably
that was reason for removal upstream.  Original idea of libwrap was
to drop illegitimate connection as soon as possible, but over the
years the code was pushed further down and down and ended in the
forked client connection handler.

The negative effects of late dropping is increasing attack surface
for hosts that are to be dropped anyway.  Apart from hypothetical
future vulnerabilities in connection handling, today a malicious
host listed in /etc/hosts.allow still can trigger sshd to enter
connection throttling mode, which is enabled by default (see
MaxStartups in sshd_config(5)), effectively casting DoS attack.
Note that on OpenBSD this attack isn't possible, since they enable
MaxStartups together with UseBlacklist.

A only negative effect from early drop, that I can imagine, is that
now main listener parses file in /etc, and if our root filesystems
goes bad, it would get stuck.  But unlikely you'd be able to login
in that case anyway.

Implementation details:

- For brevity we reuse the same struct request_info.  This isn't
  a documented feature of libwrap, but code review, viewing data
  in a debugger and real life testing shows that if we clear
  RQ_CLIENT_NAME and RQ_CLIENT_ADDR every time, it works as intended.
- We set SO_LINGER on the socket to force immediate connection reset.
- We log message exactly as libwrap's refuse() would do.

Differential revision:	https://reviews.freebsd.org/D33044
2022-01-02 18:32:30 -08:00
..
2021-12-19 11:02:02 -05:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:03:45 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2018-09-10 16:20:12 +00:00
2018-09-10 16:20:12 +00:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2018-05-11 13:22:43 +00:00
2018-05-11 13:22:43 +00:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2018-09-10 16:20:12 +00:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2018-09-10 16:20:12 +00:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2018-05-11 13:22:43 +00:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2018-05-11 13:22:43 +00:00
2018-05-11 13:22:43 +00:00
2021-09-07 21:05:51 -04:00
2018-05-11 13:22:43 +00:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:03:45 -05:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2020-02-14 19:06:59 +00:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-12-19 11:02:02 -05:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-12-19 11:02:02 -05:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2020-02-14 19:06:59 +00:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2018-09-10 16:20:12 +00:00
2021-12-19 11:02:02 -05:00
2021-12-19 11:03:45 -05:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-12-19 11:02:02 -05:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2018-09-10 16:20:12 +00:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2018-09-10 16:20:12 +00:00
2018-05-11 13:22:43 +00:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2021-12-19 11:02:02 -05:00
2021-09-07 21:05:51 -04:00
2021-09-07 21:05:51 -04:00
2018-05-11 13:22:43 +00:00
2021-09-07 21:05:51 -04:00
2018-05-11 13:22:43 +00:00
2018-05-11 13:22:43 +00:00
2021-09-07 21:05:51 -04:00
2018-05-11 13:22:43 +00:00
2021-09-07 21:05:51 -04:00
2018-05-11 13:22:43 +00:00

Portable OpenSSH

C/C++ CI Fuzzing Status

OpenSSH is a complete implementation of the SSH protocol (version 2) for secure remote login, command execution and file transfer. It includes a client ssh and server sshd, file transfer utilities scp and sftp as well as tools for key generation (ssh-keygen), run-time key storage (ssh-agent) and a number of supporting programs.

This is a port of OpenBSD's OpenSSH to most Unix-like operating systems, including Linux, OS X and Cygwin. Portable OpenSSH polyfills OpenBSD APIs that are not available elsewhere, adds sshd sandboxing for more operating systems and includes support for OS-native authentication and auditing (e.g. using PAM).

Documentation

The official documentation for OpenSSH are the man pages for each tool:

Stable Releases

Stable release tarballs are available from a number of download mirrors. We recommend the use of a stable release for most users. Please read the release notes for details of recent changes and potential incompatibilities.

Building Portable OpenSSH

Dependencies

Portable OpenSSH is built using autoconf and make. It requires a working C compiler, standard library and headers.

libcrypto from either LibreSSL or OpenSSL may also be used, but OpenSSH may be built without it supporting a subset of crypto algorithms.

zlib is optional; without it transport compression is not supported.

FIDO security token support needs libfido2 and its dependencies. Also, certain platforms and build-time options may require additional dependencies; see README.platform for details.

Building a release

Releases include a pre-built copy of the configure script and may be built using:

tar zxvf openssh-X.YpZ.tar.gz
cd openssh
./configure # [options]
make && make tests

See the Build-time Customisation section below for configure options. If you plan on installing OpenSSH to your system, then you will usually want to specify destination paths.

Building from git

If building from git, you'll need autoconf installed to build the configure script. The following commands will check out and build portable OpenSSH from git:

git clone https://github.com/openssh/openssh-portable # or https://anongit.mindrot.org/openssh.git
cd openssh-portable
autoreconf
./configure
make && make tests

Build-time Customisation

There are many build-time customisation options available. All Autoconf destination path flags (e.g. --prefix) are supported (and are usually required if you want to install OpenSSH).

For a full list of available flags, run configure --help but a few of the more frequently-used ones are described below. Some of these flags will require additional libraries and/or headers be installed.

Flag Meaning
--with-pam Enable PAM support. OpenPAM, Linux PAM and Solaris PAM are supported.
--with-libedit Enable libedit support for sftp.
--with-kerberos5 Enable Kerberos/GSSAPI support. Both Heimdal and MIT Kerberos implementations are supported.
--with-selinux Enable SELinux support.
--with-security-key-builtin Include built-in support for U2F/FIDO2 security keys. This requires libfido2 be installed.

Development

Portable OpenSSH development is discussed on the openssh-unix-dev mailing list (archive mirror). Bugs and feature requests are tracked on our Bugzilla.

Reporting bugs

Non-security bugs may be reported to the developers via Bugzilla or via the mailing list above. Security bugs should be reported to openssh@openssh.com.