This is an SSHHost class written in Python, designed to manage remote SSH connections to hosts. It uses the Paramiko library to handle SSH connections, allowing users to load SSH keys, execute commands, and update user passwords on remote hosts.
- Connect to remote hosts using SSH
- Generate a random password for users
- Execute commands on remote hosts
- Load SSH keys for authentication
- Update user passwords
- Import the
SSHHostclass in your script - Create an instance of the
SSHHostclass with the target host's IP, username, and password - Use the provided methods to interact with the remote host
from ssh_host import SSHHost
ip = "192.168.1.1"
username = "user"
password = "pass"
ssh_host = SSHHost(ip, username, password)
ssh_host.load_ssh_key()
ssh_host.update_user()
ssh_host.close()_generate_password: Generate a random password with a given lengthexecute_command: Execute a command on the remote hostclose: Close the SSH connectionload_ssh_key: Load the public SSH key and save it to the remote host'sauthorized_keysfileupdate_user: Update the user's password on the remote host
- Python 3
paramikoossocketsecretsstringmodels.logger(a custom logger module)