users operations

class reemote.operations.users.add_user.Add_user(user: str = None, password: str = None, guard: bool = True, sudo: bool = False, su: bool = False)[source]

Bases: object

A class to encapsulate the functionality of adding a user in Unix-like operating systems. It allows creating a new user account with specified password and privilege options.

user

The username to be created.

Type:

str

password

The password for the new user account.

Type:

str

guard

If False the user creation command will not be executed.

Type:

bool

sudo

If True, the user will be created with sudo privileges.

Type:

bool

su

If True, the user will be created with su privileges.

Type:

bool

Examples:

# Create a new user with password
yield Add_user(user="john", password="secret123")
# Create a user with sudo privileges
yield Add_user(user="admin", password="admin123", sudo=True)
Usage:

This class is designed to be used in a generator-based workflow where user creation commands are yielded for execution on remote hosts.

Notes

  • Privilege escalation (sudo/su) is handled based on the respective flags.

class reemote.operations.users.add_sudo_user.Add_sudo_user(user: str = None, password: str = None, guard: bool = True, sudo: bool = False, su: bool = False)[source]

Bases: object

A class to encapsulate the functionality of adding a user with sudo privileges in Unix-like operating systems. It creates a new user account and configures sudo access by adding the user to the sudoers system.

user

The username to be created with sudo privileges.

Type:

str

password

The password for the new user account.

Type:

str

guard

If False the user creation and sudo configuration will not be executed.

Type:

bool

sudo

If True, the operations will be executed with sudo privileges.

Type:

bool

su

If True, the operations will be executed with su privileges.

Type:

bool

Examples:

# Create a new user with sudo privileges
yield Add_sudo_user(user="admin", password="securepass123")
# Create a sudo user with specific privilege escalation
yield Add_sudo_user(user="deployer", password="deploy123", sudo=True)
Usage:

This class is designed to be used in a generator-based workflow where user creation and sudo configuration commands are yielded for execution on remote hosts.

Notes

  • The sudo configuration grants the user full sudo privileges (ALL=(ALL:ALL) ALL).

class reemote.operations.users.add_sudo_user1.Add_sudo_user(user: str = None, password: str = None, guard: bool = True, sudo: bool = False, su: bool = False)[source]

Bases: object

A class to encapsulate the functionality of adding a user with sudo privileges in Unix-like operating systems. It creates a new user account and configures sudo access by adding the user to the sudoers system.

user

The username to be created with sudo privileges.

Type:

str

password

The password for the new user account.

Type:

str

guard

If False the user creation and sudo configuration will not be executed.

Type:

bool

sudo

If True, the operations will be executed with sudo privileges.

Type:

bool

su

If True, the operations will be executed with su privileges.

Type:

bool

Examples:

# Create a new user with sudo privileges
yield Add_sudo_user(user="admin", password="securepass123")
# Create a sudo user with specific privilege escalation
yield Add_sudo_user(user="deployer", password="deploy123", sudo=True)
Usage:

This class is designed to be used in a generator-based workflow where user creation and sudo configuration commands are yielded for execution on remote hosts.

Notes

  • The user creation uses adduser -D to create a system user without a home directory.

  • The password is set using chpasswd for secure password assignment.

  • Sudo privileges are configured by creating a builtin in /etc/sudoers.d/ directory.

  • The operation includes cleanup of temporary builtin used during configuration.

  • The sudo configuration grants the user full sudo privileges (ALL=(ALL:ALL) ALL).

class reemote.operations.users.usermod.Usermod(user: str = None, password: str = None, sudo: bool = False, su: bool = False)[source]

Bases: object

A class to encapsulate the functionality of adding a user password in Unix-like operating systems. It allows creating a new user account with specified password and privilege options.

user

The username to be created.

Type:

str

password

The password for the new user account.

Type:

str

sudo

If True, the user will be created with sudo privileges.

Type:

bool

su

If True, the user will be created with su privileges.

Type:

bool

Examples:

yield Usermod(user="john", password="secret123")
Usage:

This class is designed to be used in a generator-based workflow where user creation commands are yielded for execution on remote hosts.

Notes

  • Privilege escalation (sudo/su) is handled based on the respective flags.

class reemote.operations.users.useradd.Useradd(user: str = None, name: str = None, sudo: bool = False, su: bool = False)[source]

Bases: object

A class to encapsulate the functionality of adding a user in Unix-like operating systems. It allows creating a new user account with specified password and privilege options.

user

The username to be created.

Type:

str

sudo

If True, the user will be created with sudo privileges.

Type:

bool

su

If True, the user will be created with su privileges.

Type:

bool

Examples:

yield Useradd(user="john",name="John Smith")
Usage:

This class is designed to be used in a generator-based workflow where user creation commands are yielded for execution on remote hosts.

Notes

  • Privilege escalation (sudo/su) is handled based on the respective flags.

class reemote.operations.users.mkpasswd.Mkpasswd(password: str, sudo: bool = False, su: bool = False)[source]

Bases: object

A class to encapsulate the functionality of adding a user password in Unix-like operating systems. It allows creating a new user account with specified password and privilege options.

password

The password for the new user account.

Type:

str

sudo

If True, the user will be created with sudo privileges.

Type:

bool

su

If True, the user will be created with su privileges.

Type:

bool

Examples:

yield Mkpasswd(password="secret123")
Usage:

This class is designed to be used in a generator-based workflow where user creation commands are yielded for execution on remote hosts.

Notes

  • Privilege escalation (sudo/su) is handled based on the respective flags.