Establish an SSH connection.
(self, ip, username, password)
| 40 | logger.error(f"Error during initialization: {e}") |
| 41 | |
| 42 | def connect_ssh(self, ip, username, password): |
| 43 | """ |
| 44 | Establish an SSH connection. |
| 45 | """ |
| 46 | try: |
| 47 | ssh = paramiko.SSHClient() |
| 48 | ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) |
| 49 | ssh.connect(ip, username=username, password=password) |
| 50 | logger.info(f"Connected to {ip} via SSH with username {username}") |
| 51 | return ssh |
| 52 | except Exception as e: |
| 53 | logger.error(f"Error connecting to SSH on {ip} with username {username}: {e}") |
| 54 | raise |
| 55 | |
| 56 | def find_files(self, ssh, dir_path): |
| 57 | """ |