Created
March 15, 2022 18:36
-
-
Save Marceloromeugoncalves/9dfd8ec960db2d4992a2d4f0b0f975c2 to your computer and use it in GitHub Desktop.
Exemplo de conexão SSH com paramiko.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install paramiko | |
import paramiko | |
address = '10.0.0.61' | |
username = 'root' | |
password = 'pythondevops' | |
ssh = paramiko.SSHClient() | |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
ssh.connect(hostname=address, username=username, password=password) | |
stdin, stdout, stderr = ssh.exec_command('ifconfig') | |
stdin.close() | |
print(stdout.readlines()) | |
for line in stdout.readlines(): | |
print(line.replace('\n', '')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment