diff --git a/netmiko/main.py b/netmiko/main.py new file mode 100644 index 0000000..434d9bb --- /dev/null +++ b/netmiko/main.py @@ -0,0 +1,39 @@ +import paramiko + +# SSH connection details +host = "172.31.142.223" +username = "admin" +password = "T15462&93016n." # Replace with actual password +command = "show access-control-config" + +# Create SSH client +ssh = paramiko.SSHClient() + +# Automatically add host key (not secure for production, consider using ssh_keys) +ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + +try: + # Connect to the host + ssh.connect(host, username=username, password=password) + + # Execute the command + stdin, stdout, stderr = ssh.exec_command(command) + + # Read the output + output = stdout.read().decode() + error = stderr.read().decode() + + # Print the output + print("Command Output:") + print(output) + + if error: + print("Error:") + print(error) + +except Exception as e: + print(f"An error occurred: {str(e)}") + +finally: + # Close the connection + ssh.close() diff --git a/netmiko/poetry.lock b/netmiko/poetry.lock new file mode 100644 index 0000000..022bbde --- /dev/null +++ b/netmiko/poetry.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand. +package = [] + +[metadata] +lock-version = "2.0" +python-versions = "^3.10" +content-hash = "53f2eabc9c26446fbcc00d348c47878e118afc2054778c3c803a0a8028af27d9" diff --git a/netmiko/pyproject.toml b/netmiko/pyproject.toml new file mode 100644 index 0000000..4c2f1b5 --- /dev/null +++ b/netmiko/pyproject.toml @@ -0,0 +1,14 @@ +[tool.poetry] +name = "netmiko" +version = "0.1.0" +description = "" +authors = ["pro100ton "] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.10" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"