All Projects → jirutka → Ssh Ldap Pubkey

jirutka / Ssh Ldap Pubkey

Licence: mit
Utility to manage SSH public keys stored in LDAP.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ssh Ldap Pubkey

Ldap Jwt
Lightweight node.js based web service that provides user authentication against LDAP server (Active Directory / Windows network) credentials and returns a JSON Web Token.
Stars: ✭ 58 (-68.65%)
Mutual labels:  ldap, authentication
Crtauth
a public key backed client/server authentication system
Stars: ✭ 109 (-41.08%)
Mutual labels:  authentication, ssh
Sshremotekeys
Managing SSH keys remotely to control access to hosts
Stars: ✭ 70 (-62.16%)
Mutual labels:  ssh, ssh-key
Eloquent Ldap
A Laravel 5.1 package that first tries to log the user against the internal database if that fails, it tries against the configured LDAP/AD server.
Stars: ✭ 19 (-89.73%)
Mutual labels:  ldap, authentication
Cedarkey
$2 hardware SSH keys storage
Stars: ✭ 148 (-20%)
Mutual labels:  ssh, ssh-key
Geofront Cli
It provides a CLI client for Geofront, a simple SSH key management server.
Stars: ✭ 30 (-83.78%)
Mutual labels:  ssh, ssh-key
Lastpass Ssh
SSH key management with LastPass
Stars: ✭ 105 (-43.24%)
Mutual labels:  ssh, ssh-key
Ssh Permit A38
Central management and deployment for SSH keys
Stars: ✭ 451 (+143.78%)
Mutual labels:  ssh, ssh-key
Diting
运维面板,运维导航,统一账号平台,运维统一平台,LDAP管理平台
Stars: ✭ 142 (-23.24%)
Mutual labels:  ldap, authentication
Awesome Ssh
💻 A curated list of SSH resources.
Stars: ✭ 1,742 (+841.62%)
Mutual labels:  ssh, ssh-key
Opscloud
运维管理平台(阿里云),自动同步阿里云配置信息,堡垒机(容器),批量运维,Kubernetes,Zabbix管理等功能
Stars: ✭ 788 (+325.95%)
Mutual labels:  ldap, ssh
Pac4j
Security engine for Java (authentication, authorization, multi frameworks): OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 2,097 (+1033.51%)
Mutual labels:  ldap, authentication
Authelia
The Single Sign-On Multi-Factor portal for web apps
Stars: ✭ 11,094 (+5896.76%)
Mutual labels:  ldap, authentication
Ssh Agent Helper
Use SSH keys from CMD, PowerShell, etc. on Windows
Stars: ✭ 31 (-83.24%)
Mutual labels:  ssh, ssh-key
Cashier
A self-service CA for OpenSSH
Stars: ✭ 590 (+218.92%)
Mutual labels:  ssh, ssh-key
Rdiffweb
A simplified backup management software for quick access to your archives through an efficient web interface.
Stars: ✭ 76 (-58.92%)
Mutual labels:  ldap, ssh-key
Play Pac4j
Security library for Play framework 2 in Java and Scala: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 375 (+102.7%)
Mutual labels:  ldap, authentication
Buji Pac4j
pac4j security library for Shiro: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 444 (+140%)
Mutual labels:  ldap, authentication
Spring Webmvc Pac4j
Security library for Spring Web MVC: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 110 (-40.54%)
Mutual labels:  ldap, authentication
Spark Pac4j
Security library for Sparkjava: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 154 (-16.76%)
Mutual labels:  ldap, authentication

OpenSSH / LDAP public keys

Build Status Code Climate version

This project provides an utility to manage SSH public keys stored in LDAP and also a script for OpenSSH server to load authorized keys from LDAP.

Why?

When you have dozen of servers it becomes difficult to manage your authorized keys. You have to copy all your public keys to ~/.ssh/authorized_keys on every server you want to login to. And what if you someday change your keys?

It’s a good practice to use some kind of a centralized user management, usually an LDAP server. There you have user’s login, uid, e-mail, … and password. What if we could also store public SSH keys on LDAP server? With this utility it’s easy as pie.

Alternatives

If you need just a lightweight utility for OpenSSH server to load authorized keys from LDAP, then you can use ssh-getkey-ldap written in Lua or this one written in POSIX shell (but it requires ldapsearch utility and may not work well on some systems).

Requirements

You can install both Python modules from PyPI. pyldap (and python-ldap) requires additional system dependencies – OpenLDAP. Refer to Stack Overflow for distribution-specific information.

Installation

PyPI:

pip install ssh-ldap-pubkey

Alpine Linux

apk add ssh-ldap-pubkey

Note: The package is currently in the (official) community repository; make sure that you have community in /etc/apk/repositories.

Usage

List SSH public keys stored in LDAP for the current user:

ssh-ldap-pubkey list

List SSH public keys stored in LDAP for the specified user:

ssh-ldap-pubkey list -u flynn

Add the specified SSH public key for the current user to LDAP:

ssh-ldap-pubkey add ~/.ssh/id_rsa.pub

Remove SSH public key(s) of the current user that matches the specified pattern:

ssh-ldap-pubkey del [email protected]

Specify LDAP URI and base DN on command line instead of configuration file:

ssh-ldap-pubkey list -b ou=People,dc=encom,dc=com -H ldaps://encom.com -u flynn

As the LDAP manager, add SSH public key to LDAP for the specified user:

ssh-ldap-pubkey add -D cn=Manager,dc=encom,dc=com -u flynn ~/.ssh/id_rsa.pub

Show help for other options:

ssh-ldap-pubkey --help

Configuration

Configuration is read from /etc/ldap.conf — file used by LDAP nameservice switch library and the LDAP PAM module. An example file is included in etc/ldap.conf. The following subset of parameters are used:

  • uri ... URI(s) of the LDAP server(s) to connect to, separated by a space. The URI scheme may be ldap, or ldaps. Default is ldap://localhost.
  • nss_base_passwd ... distinguished name (DN) of the search base.
  • base ... distinguished name (DN) of the search base. Used when nss_base_passwd is not set.
  • scope ... search scope; sub, one, or base (default is sub).
  • referrals ... should client automatically follow referrals returned by LDAP servers (default is on)?
  • pam_filter ... filter to use when searching for the user’s entry, additional to the login attribute value assertion (pam_login_attribute=<login>). Default is objectclass=posixAccount.
  • pam_login_attribute ... the user ID attribute (default is uid).
  • ldap_version ... LDAP version to use (default is 3).
  • sasl ... enable SASL and specify mechanism to use (currently only GSSAPI is supported).
  • binddn ... distinguished name (DN) to bind when reading the user’s entry (default is to bind anonymously).
  • bindpw ... credentials to bind with when reading the user’s entry (default is none).
  • ssl ... LDAP SSL/TLS method; off, on, or start_tls. If you use LDAP over SSL (i.e. URI ldaps://), leave this empty.
  • timelimit ... search time limit in seconds (default is 10).
  • bind_timelimit ... bind/connect time limit in seconds (default is 10). If multiple URIs are specified in uri, then the next one is tried after this timeout.
  • tls_cacertdir ... path of the directory with CA certificates for LDAP server certificate verification.
  • pubkey_class ... objectClass that should be added/removed to/from the user’s entry when adding/removing first/last public key and the pubkey_attr is mandatory for this class. This is needed for the original openssh-lpk.schema (not for the one in this repository). Default is ldapPublicKey.
  • pubkey_attr ... name of LDAP attribute used for SSH public keys (default is sshPublicKey).

The only required parameter is nss_base_passwd or base, others have sensitive defaults. You might want to define uri parameter as well. These parameters can be also defined/overriden with --bind and --uri options on command line.

For more information about these parameters refer to ldap.conf man page.

Setup OpenSSH server

To configure OpenSSH server to fetch users’ authorized keys from LDAP server:

  1. Make sure that you have installed ssh-ldap-pubkey and ssh-ldap-pubkey-wrapper in /usr/bin with owner root and mode 0755.

  2. Add these two lines to /etc/ssh/sshd_config:

    AuthorizedKeysCommand /usr/bin/ssh-ldap-pubkey-wrapper
    AuthorizedKeysCommandUser nobody
    
  3. Restart sshd and check log file if there’s no problem.

Note: This method is supported by OpenSSH since version 6.2-p1 (or 5.3 onRedHat). If you have an older version and can’t upgrade, for whatever weird reason, use openssh-lpk patch instead.

Setup LDAP server

Just add the openssh-lpk.schema to your LDAP server, or add an attribute named sshPublicKey to any existing schema which is already defined in people entries. That’s all.

Note: Presumably, you’ve already setup your LDAP server for centralized unix users management, i.e. you have the NIS schema and users in LDAP.

License

This project is licensed under MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].