Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use host ~/.ssh/config #118

Open
Myridium opened this issue Dec 15, 2021 · 14 comments
Open

Cannot use host ~/.ssh/config #118

Myridium opened this issue Dec 15, 2021 · 14 comments

Comments

@Myridium
Copy link

I have an SSH config setup for reMarkable in my ~/.ssh/config. I looked through the source code and it seems like there may be partial support for this, but I couldn't get it to work.

I want to be able to do rmview and have it read the same config I would normally use to ssh into the reMarkable. Instead I have a headache with a separate private key? I don't use a keyfile for SSH, I use the ssh-agent, which is provided a key by gpg-agent, which reads my PGP smart card.

The ssh-agent, and ~/.ssh/config exist for a reason... please enable support to just call the ssh command on the machine and let it worry about hostname resolution and authentication etc.

@bordaigorl
Copy link
Owner

With some care in configuring rmview this should already work.
Have a look at #75 and see if it helps you.
The idea is to use "auth_method": "key" and leave all the other parameters unspecified.
What configuration are you using at the moment?

@Myridium
Copy link
Author

Myridium commented Dec 15, 2021

{
  "ssh": {
    "address": "rm",
    "auth_method": "key",
    "timeout": 2
  },
  "orientation": "auto",
  "pen_size": 15,
  "pen_color": "red",
  "pen_trail": 200,
  "background_color": "white",
  "hide_pen_on_press": true
} 

"I could not connect to the reMarkable at rm"

It does not appear to read the ~/.ssh/config entry titled rm.

{
  "ssh": {
    "address": "remarkable",
    "auth_method": "key",
    "timeout": 2
  },
  "orientation": "auto",
  "pen_size": 15,
  "pen_color": "red",
  "pen_trail": 200,
  "background_color": "white",
  "hide_pen_on_press": true
} 

"I could not connect to the reMarkable at remarkable"

It does not appear to search for a host with hostname remarkable.

My ~/.ssh/config entry is

Host rm
    Hostname remarkable
    User root
    HostKeyAlgorithms=+ssh-rsa
    PubkeyAcceptedKeyTypes=+ssh-rsa

This works fine with ssh rm and reStream rm, for example.

Using the hostname remarkable will allow me to access the reMarkable whether it is on Wifi (with whatever IP it is assigned by the modem) and by USB. But the point is that it's robust because it searches by hostname rather than specific IP.

@bordaigorl
Copy link
Owner

Just to confirm: if you put the IP of the remarkable in the address configuration (and in your ssh config), does it work?
How is remarkable associated with the IP of the tablet?

@Myridium
Copy link
Author

Just to confirm: if you put the IP of the remarkable in the address configuration (and in your ssh config), does it work? How is remarkable associated with the IP of the tablet?

I haven't tried putting the IP in, because the IP is dynamically assigned by the network router. It doesn't make sense to hardcode an IP. That's what a hostname is for. Same way you browse to hostname.com in your browser, or ssh hostname, or ping hostname etc. For example I can run ping remarkable and get pongs back.

ssh goes a step further, allowing aliases. Above I defined an alias called rm. ssh rm looks in the .ssh/config for information on how to decode that alias, including the hostname and ssh settings.

I haven't been able to get the non-dockerised version of this app to work at all;

Unhandled Error
Traceback (most recent call last):
  File "/opt/miniconda3/lib/python3.8/site-packages/twisted/python/log.py", line 85, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/opt/miniconda3/lib/python3.8/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/opt/miniconda3/lib/python3.8/site-packages/twisted/python/context.py", line 83, in callWithContext
    return func(*args, **kw)
  File "/opt/miniconda3/lib/python3.8/site-packages/twisted/internet/posixbase.py", line 687, in _doReadOrWrite
    why = selectable.doRead()
--- <exception caught here> ---
  File "/opt/miniconda3/lib/python3.8/site-packages/twisted/internet/udp.py", line 254, in doRead
    self.protocol.datagramReceived(data, addr)
  File "/opt/miniconda3/lib/python3.8/site-packages/rmview/screenstream/screenshare.py", line 46, in datagramReceived
    if not self.callback(timestamp):
  File "/opt/miniconda3/lib/python3.8/site-packages/rmview/screenstream/screenshare.py", line 119, in runVnc
    userId = self.get_userid()
  File "/opt/miniconda3/lib/python3.8/site-packages/rmview/screenstream/screenshare.py", line 107, in get_userid
    d = jwt.decode(token, options={"verify_signature": False})
  File "/opt/miniconda3/lib/python3.8/site-packages/jwt/api_jwt.py", line 104, in decode
    self._validate_claims(payload, merged_options, **kwargs)
  File "/opt/miniconda3/lib/python3.8/site-packages/jwt/api_jwt.py", line 140, in _validate_claims
    self._validate_aud(payload, audience)
  File "/opt/miniconda3/lib/python3.8/site-packages/jwt/api_jwt.py", line 189, in _validate_aud
    raise InvalidAudienceError('Invalid audience')
jwt.exceptions.InvalidAudienceError: Invalid audience

This is after manually installing the required Python libraries. Despite them being installed on the system (packages python-pyjwt, python-paramiko, etc) they were not importable through python. That's probably an issue on my end. But anyway rmview doesn't complain about the installed versions, so I don't know the cause for the error.

Between the dockerized version expecting a different configuration path (~/.config/rmview/rmview.json instead of ~/.config/rmview.json), the native version broken, and not respecting ssh aliases, this is too much trouble for me to debug further, sorry.

@bordaigorl
Copy link
Owner

I haven't tried putting the IP in, because the IP is dynamically assigned by the network router. It doesn't make sense to hardcode an IP. That's what a hostname is for. Same way you browse to hostname.com in your browser, or ssh hostname, or ping hostname etc. For example I can run ping remarkable and get pongs back.

I understand this, but my question was: how is the remarkable hostname being resolved in your system? Where did you register it so that lookups point to the dynamic IP of the tablet? Do the lookups work from within the Docker image?
By the way you can also find the current IP from the settings panel of the tablet. My suggestion of using the IP was to help you troubleshoot this: one possible explanation is that rmview does try to follow ssh's config but cannot resolve the hostname. If it works with the IP that would confirm it, otherwise there's some other mistake.
To isolate the issue you could try connecting via Paramiko manually and see if that works (if it does then rmview is using the library incorrectly and there's a bug I can fix).

I haven't been able to get the non-dockerised version of this app to work at all;

that has probably to do with your Anaconda configuration. People used rmview with Anaconda before but they had to follow some other installation flow. I've never used Anaconda so I cannot really help you there.

Under 'releases' you can also find brebuilt binaries. I am planning to upload there new ones for the latest version soon.

this is too much trouble for me to debug further, sorry.

I was just trying to help you with your problem

@develop-Greenant
Copy link

develop-Greenant commented Mar 2, 2022

I am also getting similar Invalid audience error with pip3 install . compiled command.

I started screenshare first and SSH connection looks fine.

Running with Debian 11, python 3.9
Remarkable2 software v2.12.1.527 (latest)

log below (my user name replaced with user for privacy)

rmview 
[INFO] STARTING: Wed Mar  2 16:32:12 2022
[INFO] Searching configuration in rmview.json, /home/user/.config/rmview.json
[INFO] Using known hosts file: /home/user/.config/rmview_known_hosts
[INFO] Loaded known hosts from /home/user/.config/rmview_known_hosts
[INFO] Connecting...
[INFO] Connected to 192.168.2.113
[INFO] Detected reMarkable 2.0
[INFO] Using backend 'screenshare'
[INFO] Connecting to ScreenShare, make sure you enable it
[WARNING] Authenticating, please wait...
[INFO] received timestamp challenge 1646199139962
Unhandled Error
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.9/site-packages/twisted/python/log.py", line 80, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/user/.local/lib/python3.9/site-packages/twisted/python/context.py", line 117, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/user/.local/lib/python3.9/site-packages/twisted/python/context.py", line 82, in callWithContext
    return func(*args, **kw)
  File "/home/user/.local/lib/python3.9/site-packages/twisted/internet/posixbase.py", line 683, in _doReadOrWrite
    why = selectable.doRead()
--- <exception caught here> ---
  File "/home/user/.local/lib/python3.9/site-packages/twisted/internet/udp.py", line 254, in doRead
    self.protocol.datagramReceived(data, addr)
  File "/home/user/.local/lib/python3.9/site-packages/rmview/screenstream/screenshare.py", line 46, in datagramReceived
    if not self.callback(timestamp):
  File "/home/user/.local/lib/python3.9/site-packages/rmview/screenstream/screenshare.py", line 119, in runVnc
    userId = self.get_userid()
  File "/home/user/.local/lib/python3.9/site-packages/rmview/screenstream/screenshare.py", line 107, in get_userid
    d = jwt.decode(token, options={"verify_signature": False})
  File "/usr/lib/python3/dist-packages/jwt/api_jwt.py", line 104, in decode
    self._validate_claims(payload, merged_options, **kwargs)
  File "/usr/lib/python3/dist-packages/jwt/api_jwt.py", line 140, in _validate_claims
    self._validate_aud(payload, audience)
  File "/usr/lib/python3/dist-packages/jwt/api_jwt.py", line 189, in _validate_aud
    raise InvalidAudienceError('Invalid audience')
jwt.exceptions.InvalidAudienceError: Invalid audience

p.s. the VNC server will not be installed on the rM tablet yet as the Auto install menu prompt is not available in the rmview application - I guess it fails before offering that option.

SSH connection works fine from the host.

@develop-Greenant
Copy link

Interestingly, I have tried on same network with precompiled app (for Mac) and that works.

I guess maybe there is a build/library issue...

@bordaigorl
Copy link
Owner

bordaigorl commented Mar 2, 2022

The bundle uses pyjwt 2.1.0. This seems like a regression due to using a newer version.
Can you check if the issue persists after updating to 396acde ?

BTW, Autoinstall does nothing if the backend is screenshare as that method has no dependencies.

@develop-Greenant
Copy link

@bordaigorl that change definitely helps. I can now connect and get the first image from the rM.

However updates fail to load

Here is the log (note that I changed to key based auth in the config).

In the log shown, I tried:

  1. load rmview - initial image from rM shows properly
  2. add lines on rM - no update is shown on rmview
  3. I tried PAUSE/RESUME streaming - no image update
  4. quit

Restarting rmview loads the current image but no updates.

rmview -v
2022-03-03 12:43:45+1100 [-] Log opened.
[INFO] STARTING: Thu Mar  3 12:43:45 2022
[INFO] Searching configuration in rmview.json, /home/user/.config/rmview.json
[DEBUG] Configuration failure in rmview.json: [Errno 2] No such file or directory: 'rmview.json'
[INFO] Fetching configuration from /home/user/.config/rmview.json
[WARNING] Config file "/home/user/.config/rmview.json" is readable by others (permissions=644). If your config file contains secrets (e.g. password) you are strongly encouraged to make sure it's not readable by other users (chmod 600 /home/user/.config/rmview.json)
[DEBUG] Config values: {'ssh': {'address': '192.168.2.113', 'auth_method': 'key', 'key': '/home/user/.ssh/id_rsa', 'timeout': 2}, 'orientation': 'screenshare', 'pen_size': 15, 'pen_color': 'red', 'pen_trail': 200, 'background_color': 'white', 'hide_pen_on_press': True}
[INFO] Using known hosts file: /home/user/.config/rmview_known_hosts
[INFO] Loaded known hosts from /home/user/.config/rmview_known_hosts
[INFO] Connecting...
[INFO] Connected to 192.168.2.113
[INFO] Detected reMarkable 2.0
[INFO] Using backend 'screenshare'
[DEBUG] Stopping connection worker
[INFO] Connecting to ScreenShare, make sure you enable it
[WARNING] Authenticating, please wait...
2022-03-03 12:43:50+1100 [-] ChallengeReaderProtocol starting on 5901
2022-03-03 12:43:50+1100 [-] Starting protocol <rmview.screenstream.screenshare.ChallengeReaderProtocol object at 0x7fb3e990a910>
[INFO] received timestamp challenge 1646271768341
[INFO] Challenge: 9ed99dd4d4cf6c3d6dc05941ec1cfce4a8c74d9e49ec734eb0a8ffe11ad5df93, connecting to vnc
2022-03-03 12:43:50+1100 [-] Starting factory <rmview.screenstream.common.VncFactory object at 0x7fb3cc068f70>
[DEBUG] Stopping listening for timestamps
2022-03-03 12:43:50+1100 [-] (UDP Port 5901 Closed)
2022-03-03 12:43:50+1100 [-] Stopping protocol <rmview.screenstream.screenshare.ChallengeReaderProtocol object at 0x7fb3e990a910>
2022-03-03 12:43:50+1100 [VncClient (TLSMemoryBIOProtocol),client] Using protocol version 3.800
2022-03-03 12:43:50+1100 [VncClient (TLSMemoryBIOProtocol),client] Server: reMarkable rfb
[INFO] Connection to VNC server has been established
[DEBUG] Stopping ScreenShare streamer thread...
[INFO] Disconnecting from VNC server...
[DEBUG] ScreenShare streamer thread stopped.
[WARNING] Disconnected: Connection was closed cleanly.
2022-03-03 12:44:28+1100 [-] Stopping factory <rmview.screenstream.common.VncFactory object at 0x7fb3cc068f70>
2022-03-03 12:44:28+1100 [-] Main loop terminated.
[INFO] QUITTING: Thu Mar  3 12:44:28 2022

@develop-Greenant
Copy link

develop-Greenant commented Mar 3, 2022

p.s. also tried telnet 192.168.2.113 5900 which properly establishes connection to rM

p.p.s. I noticed that even though the lines are not updating, the pen cursor is properly showing, so streaming data must be getting through, just looks like drawn lines not updating

@develop-Greenant
Copy link

Actually, I think the lack of streaming marks may be related to other changes I made (I installed remux on my rM). Looks like streaming of changes to the Mac OS app is failing now too.

Nevertheless, I think this issue is resolved by your change in 396acde

@develop-Greenant
Copy link

develop-Greenant commented Mar 3, 2022

Hmmm, strange, I removed remux and other tolec installed packages but new lines don't update in rmview. Happy to debug if there is any output that would help solve.

@bordaigorl
Copy link
Owner

@develop-Greenant thanks for looking into this!

I see you are on RM2.

  • Is by any chance rm2fb active when you use rmview?
  • Are you using ddvk hacks?

@develop-Greenant
Copy link

@bordaigorl

I am not using any framebuffer hacks as far as I am aware (have never installed rm2fb or ddvk hacks.

I have uninstalled the tolec packages i had installed (including remux)

Unfortunately looks like that didn't fix the issue. Same problem, initial screen shown, live cursor is shown but no updates to the image as changes are made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants