linuxuser

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthorizedKeys

func AuthorizedKeys(username string) ([]string, error)

AuthorizedKeys gets the SSH authorized keys for the given Linux user

func Create

func Create(username, shell string) error

Create uses the useradd executable to create a new Linux user

func Delete

func Delete(username string, removeHomedir bool) error

Delete uses the userdel executable to remove an existing Linux user

func HasSudo

func HasSudo(username string) (bool, error)

HasSudo returns true if the Linux user has sudo privileges

func List

func List() (map[string]Details, error)

List gets a map of all "human" Linux users details from /etc/passwd

func RemoveSudo

func RemoveSudo(username string) error

RemoveSudo removes sudo privileges (if set) for a user without checking that user actually exists

func UpdateAuthorizedKeys

func UpdateAuthorizedKeys(username string, keys []string) error

UpdateAuthorizedKeys updates the SSH authorized keys for the given Linux user

func UpdateSudo

func UpdateSudo(username string, admin bool) error

UpdateSudo enables or disables sudo privileges for the given Linux user

func ValidAuthorizedKey

func ValidAuthorizedKey(key string) bool

ValidAuthorizedKey returns true if the specified key is a valid SSH public key

Types

type Details

type Details struct {
	Admin    bool
	Username string
	Shell    string
	HomeDir  string
	Uid      string
	Gid      string
}

func Get

func Get(username string) (*Details, error)

Get returns details about the specified user

func (Details) String

func (d Details) String() string

Jump to

Keyboard shortcuts

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