Open tymonx opened 2 years ago
- Is it possible to layer the package onto the base OS as a day 2 operation? Explain why or why not.
Yes. It is quite easy to compile and install under
/usr/lib64/security
location.
To clarify here, this question is about layering the package via rpm-ostree install, either on first boot or post installation. There is a package in Fedora so this is a Yes.
But as far as I understand this requires manual / coordinated setup for it to be usable thus you will not be able to configure it directly via Ignition. This makes it less interesting for inclusion in the base image as this requires manual attention anyway.
I think the best solution would be to include some kind of pam_otp.so
library (pam_google_authenticator.so
) with the Fedora CoreOS base image.
This will allow to have two-factor authentication out-of-box. This is important in deployment environments with limited access to internet or any kind of external network but remote SSH access is still required for management and maintenance. And configure it with Butane/Ignition by simple changing the /etc/ssh/sshd_config
configuration file and the /etc/pam.d/sshd
content.
It will be also possible to extend current Butane/Ignition specification with the otp
field:
passwd:
users:
- name: core
otp: true # Enable two-factor authentication OTP (One-Time Password)
ssh_authorized_keys:
- <key>
This may be a nice security feature for the Fedora CoreOS project.
To setup OTP, you need a shared secret between the client and server. Thus this will at least need another field to store this secret.
Perhaps a bit of a subjective opinion, but overall I don't think we want to push *COS user towards more customized/heavyweight SSH usage. To the contrary, we'd like to keep host-wide privileged SSH access to the minimum required for disaster discovery (and be happy if you can get rid of SSH service at all). If a user ends up in a situation where they need both interactive shell access and heavily-customized authN/authZ mechanisms, maybe they should consider some dedicated solutions like https://goteleport.com/.
@travier Yes, I'm aware of that. For now this can be handled with Butane storage.files
.
@lucab Maybe to illustrate my request I will describe from my experience how most of my deployments looks:
docker --host ssh://<ip> load
to remote machines or updating Docker Swarm stack. Unfortunately it is not only used for disaster discovery :/ SSH is the easiest way to convince IT department why at least it is requiredAnd I was thinking how to secure this more when someone expose/loose his SSH private key. Key rotation and revocation can be hard because it requires constant access to network and some customers automatically revoke accesses over time. TOTP works offline.
We discussed this in the community meeting today.
12:10:05 dustymabe | #agreed We will not add google-authenticator-libpam for now.
| Overlaying the package on first-boot is the currently
| recommended approach. It should be investigated if SSSD would be
| able to perform 2FA.
That being said there were some other points of discussion during the meeting that are worth bringing up:
if I'm not mistaken it requires some external centralized provider like FreeIPA, LDAP or Kerberos? I have looked into sssd code and I saw only OTP abstraction to these providers but any kind of OTP implementation. Other sssd services like files, simple, sudo don't provide any kind of OTP support. But I'm not expert in sssd. Still I don't have any possibility to setup full realm domain.
How about pre-installing /usr/lib64/security/pam_oath.so
from the existing pam_oath
package? And how to resolve chicken-egg problem for SSH+OTP without OTP after OS installation? Without external internet access to install it with the ostree-rpm? Go with CoreOS Assembler and custom image?
On the first question:
- It was suggested during the meeting that SSSD, which we already ship, may be able to handle this use case already.
I talked to a few experts on this:
@sgallagher: I know that SSSD supports two-factor authentication when used with FreeIPA (which supports both TOTP and HOTP authenticators). I don't know if there's a general implementation, though. CCing Sumit Bose to comment.
@sumit-bose I'm sorry there is no general OTP implementation in SSSD.
@tymonx - you are right.
On the second question:
- Can anyone show us how you would provision multiple nodes using Ignition and take advantage of this PAM module?
- i.e. getting the shared secret onto the nodes and configuring PAM to use the module.
- also would you be using the same shared key across all N nodes, or a different key per node?
@tymonx if I gave you a dev build with this package included could you show us exactly how you would use it? i.e. what Ignition config you would use to deploy everything with no manual interaction?
@dustymabe I do something like this:
config.yml
with included SSH public keys, included Docker Swarm Compose stack YAML files, enable Docker service, custom systemd services for creating Docker Swarm cluster and auto-joining nodes in Docker Swarm cluster and starting Docker Swarm stacks. Everything is automated including machine awareness and discovery in included custom systemd servicesconfig.ign
iso.yml
that contains custom auto-install systemd service with coreos-installer install --ignition-file /home/core/config.ign <auto-disk-detection>
. Include generated Ignition from 2. config.ign
iso.ign
for ISOiso.ign
using coreos-installer iso ignition embed --ignition-file iso.ign <fedora-coreos>.iso
iso.ign
for N remote machines. It depends on platform and BMC. For example I may use racadm
for Dell, Remote Virtual Media or Redfish APIMasterControl
to create single connection and provide required password and/or TOTP pin~/.ssh/config
to attach <ip|hostname>
connection to MasterControl
connectiondocker --host ssh://core@<ip|hostname> load <images>
docker --host ssh://core@<ip|hostname> load <images>
and docker --host ssh://core@<ip|hostname> stack deploy --compose-file stack.yml <name>
Example config.yml
:
passwd:
users:
- name: core
ssh_authorized_keys:
- <key>
storage:
files:
- path: /etc/pam.d/sshd # Set auth *.so
- path: /etc/ssh/sshd_config # Set ChallengeResponseAuthentication to yes, set UsePAM to yes, set AuthenticationMethods to publickey,password publickey,keyboard-interactive
- path: /home/core/.google_authenticator # Include generated shared OTP secrets
This will work only for google-authenticator-libpam
but should also for pam_oath
(the /home/core/.google_authenticator
path will be different). Everything works. The only missing thing in Fedora CoreOS ISO image is PAM module that will support TOTP out-of-box.
I can create a public git sample project with Butane YAML to show how to setup SSH + OTP for Fedora CoreOS. I already have some little experience with custom derived Fedora CoreOS and I can prepare configuration that will include preinstalled OTP PAM module (google-authenticator-libpam
or pam_aoth
). With instruction how to test it with qemu
or libvirt
.
I can also prepare an example for Fedora CoreOS Documentation to show how to setup and use SSH with OTP. This should be a nice security add-on for everyone who like to harden their deployments.
Project: google-authenticator-libpam
Fedora Magazine article: Set up two-factor authentication for SSH on Fedora
Please try to answer the following questions about the package you are requesting:
No additional dependencies. It is a pure C source code that is normally compiling using any existing C compiler with PAM headers. It uses the same dependencies like any other existing PAM modules. All required dynamic libraries are already present in the Fedora CoreOS:
linux-vdso.so.1
libpam.so.0
libdl.so.2
libc.so.6
libaudit.so.1
libeconf.so.0
libm.so.6
/lib64/ld-linux-x86-64.so.2
libcap-ng.so.0
For the
x86_64
architecture without any fancy build options around 129kB.Two-factor authorization for remote SSH access. This will greatly improve security for deployment OS.
No. It is strictly configured using PAM configuration files configured by system administrator (or using Butane/Ignition).
No.
No.
Yes. It is quite easy to compile and install under
/usr/lib64/security
location.Yes. It requires only compiled
pam_*.so
library and install under/usr/lib64/security
location.I don't believe so.
Yes like CVE-2012-6140.