etcdsshd

package module
v0.0.0-...-5f555c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2018 License: MIT Imports: 12 Imported by: 0

README

etcd-passwd

Passwd management by etcd. This is a test project to manage linu users on etcd.

Install

Install libnss_etcd.so.2 to your local:

# build libnss_etcd.so.2
$ make

# install to /usr/lib
$ make install

Configure your nsswitch.conf to use libnss_etcd.so.2

# /etc/nsswitch.conf
passwd:         compat etcd

Then launch etcd on localhost:2379:

$ etcd

User management

Add user peter:

$ go run cmd/etcdadduser/main.go -name peter -uid 10000 -gid 10000 -gecos 'Peter Rabbit'

You can see added user on etcd

$ ETCDCTL_API=3 etcdctl get --print-value-only  /etcd-sshd/users/10000
{"Name":"peter","Passwd":"!","UID":10000,"GID":10000,"Gecos":"Peter Rabbit","Dir":"/home/peter","Shell":"/bin/sh"}
# Invalidate cache for passwd in getent
$ sudo nscd --invalidate=passwd

# get by `getent`
$ getent passwd peter
peter:!:10000:10000:Peter Rabbit:/home/peter:/bin/sh

# be peter
$ sudo -u peter id
uid=10000(peter) gid=10000 groups=10000

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound error = errors.New("not found")

Functions

func AddUser

func AddUser(p *Passwd) error

func RegisterPasswd

func RegisterPasswd(pwd PasswdInterface)

Types

type EtcdPasswd

type EtcdPasswd struct {
	// contains filtered or unexported fields
}

func (*EtcdPasswd) Endpwent

func (e *EtcdPasswd) Endpwent() error

func (*EtcdPasswd) Getpwent

func (e *EtcdPasswd) Getpwent() (*Passwd, error)

func (*EtcdPasswd) Getpwnam

func (e *EtcdPasswd) Getpwnam(name string) (*Passwd, error)

func (*EtcdPasswd) Getpwuid

func (e *EtcdPasswd) Getpwuid(uid UID) (*Passwd, error)

func (*EtcdPasswd) Setpwent

func (e *EtcdPasswd) Setpwent() error

type GID

type GID uint

type Passwd

type Passwd struct {
	Name   string
	Passwd string
	UID    UID
	GID    GID
	Gecos  string
	Dir    string
	Shell  string
}

type PasswdInterface

type PasswdInterface interface {
	Setpwent() error
	Endpwent() error
	Getpwent() (*Passwd, error)

	Getpwnam(name string) (*Passwd, error)
	Getpwuid(uid UID) (*Passwd, error)
}

type UID

type UID uint

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL