Up and Running With Bless and Enforced MFA - Part 1
I finally got Netflix’s Bless running in production using a forked version of Lyft’s client. This post will focus on the first and easier portion: Bless in Lambda
Prerequisites
Time and terraform. I like terraform because I dislike cloudformation. Feel free to adapt.
Installing Bless
This is actually the easiest part, because it’s straight forward. Side note: I like bless because of its simplicity. It uses lambda + KMS and nothing more. The permissions are stupid simple. The purpose, after talking to one of the guys behind it, was to make it feel native and un-intrusive. It works.
Setup Config
This was the hardest to get going, because configuration always is. The readme says to paste in a function to lambda to generate your password. But thats not needed with the super awesome lambda container from lambci. To do this, create a file function.py with the contents:
This is an example of what my client config looks like:
12345678910111213141516171819202122232425262728
[MAIN]
region_aliases: east
kms_service_name: bless
bastion_ips: 192.168.1.6
remote_user: ec2-user
[CLIENT]
domain_regex: (.*\.mycompany\.com|.*\.example\.net|\A10\.[0-9](?:\.[0-9]{1,3}){2}\Z)$
cache_dir: .bless/session
cache_file: bless_cache.json
mfa_cache_dir: .aws/session
mfa_cache_file: token_cache.json
ip_urls: https://api.ipify.org, https://canihazip.com
update_script: update_blessclient.sh
[LAMBDA]
user_role: bless-client
account_id: my account id
functionname: bless
functionversion: $LATEST
certlifetime: 120
ipcachelifetime: 120
timeout_connect: 30
timeout_read: 30
[REGION_EAST]
awsregion: us-east-1
kmsauthkey: my kms id that i used for the original password encrypt
Test
You should now have a lambda that can generate certificates to use. You’ll need to put the public keys from foo1.pub and foo2.pub into your servers at /etc/ssh/cas.pub and add TrustedUserCAKeys /etc/ssh/cas.pub to /etc/ssh/sshd_config You can test this with their client: