Giter Club home page Giter Club logo

ldap-sshkp's Introduction

ldap-sshkp

LDAP-backed OpenSSH key provider written in Haskell. Intended to be a replacement for goklp.

Usage

$ ldap-sshkp--help
ldap-sshkp v0.1.0.0, (C) Carl Richard Theodor Schneider

ldap-sshkp [OPTIONS] USER
  Fetches SSH public keys for USER from the specified LDAP

LDAP settings:
  -h --host=ITEM        LDAP Hostname (Default: localhost)
  -p --port=NAT         LDAP port (Default: 368)
     --usetls           Uses TLS for LDAP connection
     --useinsecuretls   Do not verify TLS certificates
     --binddn=ITEM      DN used to bind against LDAP
     --bindpass=ITEM    Password used for binding
Search Settings:
     --basedn=ITEM      DN used as base for searching
  -s --searchattr=ITEM  Attribute for matching (Default: uid)
  -v --valueattr=ITEM   Attribute containing public keys (Default:
                        sshPublicKey)
  -t --timeout=INT      Timeout for LDAP search
Search Scopes (Only one possible):
     --single-level     Constrain search to immediate subordinates of baseDN
                        (Default)
     --base-object      Constrain search to the baseDN
     --whole-subtree    Constrain search to all subordinates of baseDN
  -? --help             Display help message
  -V --version          Print version information
     --numeric-version  Print just the version number

ldap-sshkp fetches SSH public keys from LDAP.

Use in OpenSSH

The intended use of this helper utility is with the AuthorizedKeysCommand setting for sshd from OpenSSH.

Wrapping one or multiple calls to ldap-sshkp in a script with appropriate permissions allows OpenSSH to fetch the SSH public keys from LDAP, while keeping the password used for binding against LDAP in a separate file (which needs to be accessible only for AuthorizedKeysCommandUser).

sshd_config

AuthorizedKeysCommandUser nobody
AuthorizedKeysCommand /etc/ssh/openssh-authorized-keys

/etc/ssh/openssh-authorized-keys

#!/usr/bin/bash
set -o errexit
set -o nounset
set -o pipefail

ldap-sshkp \
  --host=localhost \
  --port=389 \
  --binddn="cn=openssh,dc=example,dc=org" \
  --bindpass="$(cat /path/to/passwordfile/accessible/for/nobody)" \
  --basedn="ou=posix,dc=example,dc=org" \
  --searchattr="uid" \
  --valueattr="sshPublicKey" \
  --timeout=10 \
  --single-level \
  "$1";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.