@ -10,6 +10,7 @@ import struct
from getpass import getpass
from getpass import getpass
import paramiko
import paramiko
import paramiko . agent
logging . basicConfig ( format = ' %(message)s ' )
logging . basicConfig ( format = ' %(message)s ' )
log = logging . getLogger ( __name__ )
log = logging . getLogger ( __name__ )
@ -27,6 +28,14 @@ def open_remote_device(args, file='/dev/input/event0'):
"""
"""
log . info ( " Connecting to input ' {} ' on ' {} ' " . format ( file , args . address ) )
log . info ( " Connecting to input ' {} ' on ' {} ' " . format ( file , args . address ) )
client = paramiko . SSHClient ( )
client . set_missing_host_key_policy ( paramiko . AutoAddPolicy ( ) )
pkey = None
password = None
agent = paramiko . agent . Agent ( )
if args . key is not None :
if args . key is not None :
password = None
password = None
try :
try :
@ -42,14 +51,12 @@ def open_remote_device(args, file='/dev/input/event0'):
elif args . password :
elif args . password :
password = args . password
password = args . password
pkey = None
pkey = None
els e :
elif not ag ent . get_keys ( ) :
password = getpass (
password = getpass (
" Password for ' {} ' : " . format ( args . address )
" Password for ' {} ' : " . format ( args . address )
)
)
pkey = None
pkey = None
client = paramiko . SSHClient ( )
client . set_missing_host_key_policy ( paramiko . AutoAddPolicy ( ) )
client . connect (
client . connect (
args . address ,
args . address ,
username = ' root ' ,
username = ' root ' ,
@ -58,6 +65,10 @@ def open_remote_device(args, file='/dev/input/event0'):
look_for_keys = False
look_for_keys = False
)
)
session = client . get_transport ( ) . open_session ( )
paramiko . agent . AgentRequestHandler ( session )
# Start reading events
# Start reading events
_ , stdout , _ = client . exec_command ( ' cat ' + file )
_ , stdout , _ = client . exec_command ( ' cat ' + file )