Add some netmiko playgrounds

This commit is contained in:
pro100ton 2025-07-02 11:44:39 +03:00
parent ac62f97929
commit 2e6a44c569
3 changed files with 60 additions and 0 deletions

39
netmiko/main.py Normal file
View file

@ -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()

7
netmiko/poetry.lock generated Normal file
View file

@ -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"

14
netmiko/pyproject.toml Normal file
View file

@ -0,0 +1,14 @@
[tool.poetry]
name = "netmiko"
version = "0.1.0"
description = ""
authors = ["pro100ton <pro100ton@gmail.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"