Package: kerb-sts
AWS KERBEROS STSBased on the ADFS-CLI scriptoriginally posted by Quint Van Deman.OverviewThis script provides a seamless mechanism for federating the AWS CLI. When properly configured, this script allows a user to get a short lived (1 hour) set of credentials for each authorized role.The script leverages Kerberos and aSAML-compatible IdPto avoid any need for the user to enter
an AD domain password, or provide AWS credentials. However, users can also
authenticate using NTLM with their username and password or with a Kerberos keytab.Seeour security policyfor handling of security-related matters.ConfigurationKerb-STS looks for configuration in the ~/.kerb-sts/config.json file. This file contains the following fields:FieldRequired?Descriptionidp_urlYesURL where the SAML authentication requests are sentadfs_urlNodeprecatedURL where the SAML authentication requests are sentregionYesRegion for AWS credentialskerb_domainNoDomain name used for the Kerberos GSS exchange. This is set to the domain name ofidp_urlby defaultpreferred_auth_typeNoType of authentication to use when a username and password is submitted. Acceptable values:ntlm(default),kerberosUsers can generate this file with Kerb-STS:kerb-sts --configureThis will prompt the user for those values and then serialize the configuration. Users
can also manually create the configuration file. A sample for AD FS is demonstrated below:{
  "region": "us-east-1",
  "idp_url": "https://sample.domain.com/adfs/ls/IdpInitiatedSignOn.aspx?loginToRp=urn:amazon:webservices"
}Users can override either of the configured values on the command line.InstallationNote: Python 2.7.10 is the minimal version supportedNote: All platforms have been tested with both Python 2.7 and 3.5OSXNote: If you are using El Capitan or Sierra, refer to the subsequent OSX sectionsudo easy_install pipsudo pip install kerb-stsOSX - El CapitanNote: El Capitan forces the version of some modules which directly interfere with kerb-sts. In order to
get it to work users need to either use a version of Python that was not included with the OS or need
to follow these instructions which leverage virtual environments.sudo easy_install pip virtualenvvirtualenv ~/kerb-stssource ~/kerb-sts/bin/activatesudo pip install kerb-sts --ignore-installed sixdeactivatesudo ln -s ~/kerb-sts/bin/kerb-sts /usr/local/bin/kerb-stsMacOS SierraYou will need to update your version of Python to 2.7.12+; Homebrew is the easiest method.You will also need to install/update the XCODE Development Extensions
1a. sudo xcode-select installYou can then just run sudo pip install kerb-stsWindowsInstallPythonEnsure python and python/scripts are on the PATHInstall pywin32 frommhammond/pywin32. Follow the instructions to ensure you get the correct version.pip install kerb-stsUbuntusudo apt-get updatesudo apt-get install -y krb5-kdc libkrb5-dev python-setuptools python3-pipsudo pip install kerb-stsUsageIf the install went smoothlykerb-stsshould be on your path. There are a lot of configuration options.
The best way to discover them is to check out the help statement.kerb-sts --helpDefault RoleThe script allows users to specify an AWS IAM role that will be set as the default IAM role in
the credentials file.kerb-sts -r [iam-role-to-assume]All subsequent AWS CLI commands will use this role by default.Additionally, all available roles will be added as named profiles to the credentials file.
Users can then leverage the default role or use the AWS_DEFAULT_PROFILE environment variable to
select a specific role/profile. You can find more information about the credentials file
in theAWS Documentation.Only RoleIf you have a lot of roles available, it may take a while to process all available roles.
In this case, you can use the-ooption and only the specified role will be processed.
It will also be treated as the default role (-roption).DaemonBy passing in a--daemonflag, the script will continue running and update the credentials file every
half hour. The refresh time can be set with the--refreshargument, but remember
the tokens only last for one hour.kerb-sts -r iam-role-to-assume --daemonAuthenticating with Username/Passwordkerb-sts -u username -p 'password' -d DOMAINBased on the value ofpreferred_auth_typein your config file, this call with authenticate using NTLM, or will create a kerberos ticket for the inputted user and authenticate.KeytabThis script allows users to generate Kerberos tokens with Kerberos keytabs. Keytabs
are private key files that are signed with the user's name, domain, and password.
You can generate a keytab by running:ktutil -k username.keytab add -p username@DOMAIN.COM -e arcfour-hmac-md5 -V 1Users can use the keytab to authenticate with Kerberos by running:kinit -kt username.keytab username@DOMAIN.COMKeytabs allow users to authenticate without their password. The keytab is signed with the password however, so
when a password is updated the keytab must likewise be updated.
They can then be used with kerb-sts to generate temporary tokens:kerb-sts --key username.keytab -u username -d DOMAIN.COMCredential FileThe default location for the AWS credentials file is ~/.aws/credentials. Users are also able to specify
a different location for the credentials generated.kerb-sts -c ./aws-credentialsTroubleshootingKerberosIf you are having issues authenticating with Kerberos, make sure you can runkinit. This should prompt you for
your password and then login successfully. You can view your current Kerberos tickets withklist. If you want to
ensure Kerberos is working properly you can delete all of your tickets withkdestroy -Aand then try to get another
ticket issued by runningkinit.Building a DistributionPythonThe easiest way to install and distribute kerb-sts is using a wheel.
A distribution can be built by running:python setup.py bdist_wheelThat should output a .whl file in the dist directory which can be installed with pip.Windows EXEKerb-STS can also be built into a standalone executable with Python bundled to ease installation.python setup.py install
pip install pyinstaller
pyinstaller --onfile kerb_sts/__main__.pyThis will produce a dist/__main__.exe which can then be renamed/run as a standalone exe.DevelopmentThe recommended way to install locally from source is to use a virtual environment. From the root
of the kerb-sts source code directory run:pip install virtualenvvirtualenv venvsource venv/bin/activatepython setup.py installpython kerb_sts/