Skip to content

Instantly share code, notes, and snippets.

@Marceloromeugoncalves
Created March 15, 2022 18:36
Show Gist options
  • Save Marceloromeugoncalves/9dfd8ec960db2d4992a2d4f0b0f975c2 to your computer and use it in GitHub Desktop.
Save Marceloromeugoncalves/9dfd8ec960db2d4992a2d4f0b0f975c2 to your computer and use it in GitHub Desktop.
Exemplo de conexão SSH com paramiko.
# 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