Skip to content

Instantly share code, notes, and snippets.

@henzef
Created February 22, 2021 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henzef/4e553fad2335227b8f6b4550cd3fa543 to your computer and use it in GitHub Desktop.
Save henzef/4e553fad2335227b8f6b4550cd3fa543 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import paramiko
import logging
host = "127.0.0.1"
port = 22
username = "youruser"
password = "password"
command = "ls"
def main():
logging.basicConfig(level=0)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, username) # <- freezes
stdin, stdout, stderr = ssh.exec_command(command)
print(stdout.readlines())
if __name__ == "__main__":
import sys
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment