Git Product home page Git Product logo

ypldap-migration's Introduction

Migration Script: OpenBSD Local Users to YP LDAP ypldap

I wrote this script to pull in users from files in /etc into ldif files for use with OpenBSD's ldapd and ypldap.

This Awk script will read users and groups from /etc/master.passwd and /etc/group. By default it will only pull users and groups with a UID or GID in the range 1000 to 3000. At the top of the script you can configure the UID and GID range which will be copied.

The following ldif files will be created:

  • base.ldif = Contains the structure of the LDAP database
  • group.ldif = Contains the groups read from /etc/group
  • passwd.ldif = Contains the users read in from /etc/master.passwd

/ldap

Included in the ldap directory is a set of LDAP schema files for use with OpenBSD's ldapd and ypldap.

I have modified the nis.schema which ships with OpenBSD-5.7 in order for the posixAccount to support the attributes shadowPassword, shadowExpire, modifyTimestamp, and userClass. You must use these ldap schema files in order to use this ypldap system.

  • shadowPassword = Stores the users OpenBSD Blowfish password hash used by YP
    • userPassword = set to {BSDAUTH}username so LDAP Binds happen ageist YP and the Blowfish password hash
  • modifyTimestamp = Used as time by which user must change their password: change
  • shadowExpire = Use as time the user's account expired: expire
  • userClass = Used as the users Login Class: class

/etc

Included in the etc directory are configuration files for OpenBSD's ldapd and ypldap

With OpenBSD configured in this way, user authentication happens completely natively. Users can authenticate agents the default login class. The passwords are checked against a normal OpenBSD Blowfish password hash via the YP wrapper service ypldap. LDAP Binds are checked via {BSDAUTH} which uses YP to check the Blowfish password hash.

Tested and Used on:

Using the migration script

You must have openldap-client installed.

pkg_add openldap-client

If you have the file /etc/myname on your system with your domain name in it, you can simply run the script with no parameters. If you do not have that file or if you simply want to create the ldif file for a different domain name, you can simply specify the domain name as the first parameter.

The script must be run as the root user, so /etc/master.passwd can be read.

ypldap-migration
#  or specify the domain
ypldap-migration example.com

Then you can add the ldif files to your running OpenBSD ldapd server.

ldapadd -H ldap://ldap01.example.com -D 'cn=admin,dc=example,dc=com' -x -W -f base.ldif
ldapadd -H ldap://ldap01.example.com -D 'cn=admin,dc=example,dc=com' -x -W -f group.ldif
ldapadd -H ldap://ldap01.example.com -D 'cn=admin,dc=example,dc=com' -x -W -f passwd.ldif

You will want to compact and index your OpenBSD ldapd database.

ldapctl compact
ldapctl index

####### vim: set ts=4 sw=4 tw=80 et :######

ypldap-migration's People

Contributors

grayed avatar

Watchers

 avatar

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.