Browse Source

feat: option to use ssh agent

master
Andrew Somerville 4 years ago
parent
commit
ca46931c91
  1. 2
      README.md
  2. 17
      remarkable_mouse/remarkable_mouse.py

2
README.md

@ -15,7 +15,7 @@ pip install remarkable-mouse @@ -15,7 +15,7 @@ pip install remarkable-mouse
remouse
```
By default, `10.11.99.1` is used as the address. Seems to work pretty well wirelessly, too.
By default, `10.11.99.1` is used as the address. Seems to work pretty well wirelessly, too. By default ssh-agent is used to authenticate if it is available, otherwise you are asked for your password.
# Examples

17
remarkable_mouse/remarkable_mouse.py

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

Loading…
Cancel
Save