atsign-foundation / noports

Connect to any device with no external listening ports open
https://noports.com
BSD 3-Clause "New" or "Revised" License
272 stars 15 forks source link

v3.4.2 SSHNPD v4.0.2 SSHNP - Not Working #630

Closed JeremyTubongbanua closed 11 months ago

JeremyTubongbanua commented 11 months ago

Describe the bug

I have my Pi using v3.4.2 (Qt Plant) and I was able to use SSHNP v3.4.2 just fine, but SSHNP v4.0.2 client does not work.

SSHNP v4.0.2 logs (MacOS Client arm64):

jeremytubongbanua@Jeremys-Air ~ % ~/.local/bin/sshnp -f @client_0 -t @server_0 -d pi8 -h @rv_eu -i ~/.ssh/id_ed25519 -v
INFO|2023-12-13 15:11:05.474779|Sshnp|Finding a spare local port 
INFO|2023-12-13 15:11:05.475047|Sshnp|Initializing SshnpLocalSshKeyHandler 
INFO|2023-12-13 15:11:05.475071|Sshnp|Loading identity key pair from /Users/jeremytubongbanua/.ssh/id_ed25519 
INFO|2023-12-13 15:11:05.475485|Sshnp|Initializing SshnpCore 
INFO|2023-12-13 15:11:05.475502| SshnpdChannel |Starting monitor for notifications with regex: "68839f5c-3643-46fd-ba56-e2bff31dafd4.pi8.sshnp@server_0" 
INFO|2023-12-13 15:11:05.475512| SshnpdChannel |Subscribing to notifications with regex: "68839f5c-3643-46fd-ba56-e2bff31dafd4.pi8.sshnp@server_0" 
INFO|2023-12-13 15:11:05.793124| SshnpdChannel |Skipped sharing public key with sshnpd: sendSshPublicKey=false 
INFO|2023-12-13 15:11:05.793172| SshrvdChannel |Subscribing to notifications with regex: "68839f5c-3643-46fd-ba56-e2bff31dafd4.sshrvd@" 
INFO|2023-12-13 15:11:05.793192| SshrvdChannel |Started listening for sshrvd response 
INFO|2023-12-13 15:11:05.793205| SshrvdChannel |Sending notification to sshrvd: @rv_eu:pi8.sshrvd@client_0 
INFO|2023-12-13 15:11:06.464565| SshrvdChannel |Received host and port from sshrvd: 85.239.63.180:38181 
INFO|2023-12-13 15:11:06.464616| SshrvdChannel |Set sshrvdPort to: 43167 
INFO|2023-12-13 15:11:06.532678| SshrvdChannel |SUCCESS:id: ad9385c7-c0c2-4b84-bf3b-fa8691968c54 status: NotificationStatusEnum.delivered with key: @rv_eu:pi8.sshrvd@client_0 
INFO|2023-12-13 15:11:06.532801|Sshnp|Sending request to sshnpd 
INFO|2023-12-13 15:11:07.286528|Sshnp|SUCCESS:id: d46ca5bb-cf16-4ceb-b821-87d67a11c0d6 status: NotificationStatusEnum.delivered with key: @server_0:ssh_request.pi8.sshnp@client_0 
INFO|2023-12-13 15:11:09.224260| SshnpdChannel |Still waiting for sshnpd response 
INFO|2023-12-13 15:11:09.224396| SshnpdChannel |sshnpdAck: SshnpdAck.notAcknowledged 
INFO|2023-12-13 15:11:11.263577| SshnpdChannel |Still waiting for sshnpd response 
INFO|2023-12-13 15:11:11.263732| SshnpdChannel |sshnpdAck: SshnpdAck.notAcknowledged 
INFO|2023-12-13 15:11:13.305755| SshnpdChannel |Still waiting for sshnpd response 
INFO|2023-12-13 15:11:13.305858| SshnpdChannel |sshnpdAck: SshnpdAck.notAcknowledged 
INFO|2023-12-13 15:11:15.347889| SshnpdChannel |Still waiting for sshnpd response 
INFO|2023-12-13 15:11:15.348040| SshnpdChannel |sshnpdAck: SshnpdAck.notAcknowledged 
INFO|2023-12-13 15:11:17.388845| SshnpdChannel |Still waiting for sshnpd response 
INFO|2023-12-13 15:11:17.388955| SshnpdChannel |sshnpdAck: SshnpdAck.notAcknowledged 
sshnpd did not acknowledge the request

Stack Trace: #0      SshnpOpensshLocalImpl.run (package:noports_core/src/sshnp/impl/sshnp_openssh_local_impl.dart:88)
<asynchronous suspension>
#1      main.<anonymous closure> (file:///Users/chant/src/af/sshnoports/packages/sshnoports/bin/sshnp.dart:79)
<asynchronous suspension>
#2      main (file:///Users/chant/src/af/sshnoports/packages/sshnoports/bin/sshnp.dart:39)
<asynchronous suspension>

SSHNPD v3.4.2 (Qt Plant on Raspberry Pi 4B AARCH64):

~/.local/bin/sshnpd@client_0
INFO|2023-12-13 15:11:01.766646|AtClientManager|setCurrentAtSign called with atSign @server_0 
INFO|2023-12-13 15:11:01.767512|AtClientManager|Switching atSigns from null to @server_0 
INFO|2023-12-13 15:11:01.775488|HiveBase|commit_log_055719601711c762ce6bc501676e84468ea43ee6a20f32649e09e7cf951c9526 initialized successfully 
INFO|2023-12-13 15:11:01.782713|HiveBase|055719601711c762ce6bc501676e84468ea43ee6a20f32649e09e7cf951c9526 initialized successfully 
INFO|2023-12-13 15:11:01.787252|AtClientCommitLogCompaction (@server_0)|Starting commit log compaction job running for every 11 minute(s) 
INFO|2023-12-13 15:11:01.789817|AtClientManager|setCurrentAtSign complete 
INFO|2023-12-13 15:11:01.789923|AtLookup|Creating new connection 
INFO|2023-12-13 15:11:02.225718|AtLookup|New connection created OK 
INFO|2023-12-13 15:11:02.349367|AtLookup|auth success 
INFO|2023-12-13 15:11:02.649399| sshnpd |Starting heartbeat 
INFO|2023-12-13 15:11:02.649519| sshnpd |Subscribing to pi8\.sshnp@ 
INFO|2023-12-13 15:11:02.649660| sshnpd |Updating device info for pi8 
INFO|2023-12-13 15:11:02.787426| sshnpd |Done 
INFO|2023-12-13 15:11:02.868482|Monitor (@server_0)|monitor started for @server_0 with last notification time: null 
INFO|2023-12-13 15:11:06.892959| sshnpd |Received: ssh_request 
INFO|2023-12-13 15:11:06.893117| sshnpd |>=3.5.0 request for ssh received from @client_0 ( notification id : d46ca5bb-cf16-4ceb-b821-87d67a11c0d6 ) 
Error: type 'Null' is not a subtype of type 'String'
Stack Trace: #0      SSHNPDImpl._handleSshRequestNotification (package:sshnoports/sshnpd/sshnpd_impl.dart:381)
#1      SSHNPDImpl._notificationHandler (package:sshnoports/sshnpd/sshnpd_impl.dart:253)
#2      _rootRunUnary (dart:async/zone.dart:1415)
#3      _CustomZone.runUnary (dart:async/zone.dart:1308)
#4      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217)
#5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339)
#6      _DelayedData.perform (dart:async/stream_impl.dart:515)
#7      _PendingEvents.handleNext (dart:async/stream_impl.dart:620)
#8      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591)
#9      _rootRun (dart:async/zone.dart:1391)
#10     _CustomZone.run (dart:async/zone.dart:1301)
#11     _CustomZone.runGuarded (dart:async/zone.dart:1209)
#12     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1249)
#13     _rootRun (dart:async/zone.dart:1399)
#14     _CustomZone.run (dart:async/zone.dart:1301)
#15     _CustomZone.runGuarded (dart:async/zone.dart:1209)
#16     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1249)
#17     _microtaskLoop (dart:async/schedule_microtask.dart:40)
#18     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49)
#19     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:123)
#20     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:405)
#21     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)
#22     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189)

INFO|2023-12-13 15:11:16.978215|AtClientManager|setCurrentAtSign called with atSign @server_0 
INFO|2023-12-13 15:11:16.979081|AtClientManager|Switching atSigns from null to @server_0 
INFO|2023-12-13 15:11:16.984517|HiveBase|commit_log_055719601711c762ce6bc501676e84468ea43ee6a20f32649e09e7cf951c9526 initialized successfully 
INFO|2023-12-13 15:11:16.991785|HiveBase|055719601711c762ce6bc501676e84468ea43ee6a20f32649e09e7cf951c9526 initialized successfully 
INFO|2023-12-13 15:11:16.999426|AtClientCommitLogCompaction (@server_0)|Starting commit log compaction job running for every 11 minute(s) 
INFO|2023-12-13 15:11:17.006372|AtClientManager|setCurrentAtSign complete 
INFO|2023-12-13 15:11:17.006610|AtLookup|Creating new connection 
INFO|2023-12-13 15:11:17.309714|AtLookup|New connection created OK 
INFO|2023-12-13 15:11:17.398373|AtLookup|auth success 
INFO|2023-12-13 15:11:17.678379| sshnpd |Starting heartbeat 
INFO|2023-12-13 15:11:17.678469| sshnpd |Subscribing to pi8\.sshnp@ 
INFO|2023-12-13 15:11:17.678590| sshnpd |Updating device info for pi8 
INFO|2023-12-13 15:11:17.771436| sshnpd |Done 
INFO|2023-12-13 15:11:17.906380|Monitor (@server_0)|monitor started for @server_0 with last notification time: null

Additional Logs:

Pi start up script sshnpd:

jeremy@raspberrypi8:~ $ cat ~/.local/bin/sshnpd@client_0
#!/bin/bash
# v2.0.0
# allow machine to bring up network
sleep 10
USER=$(whoami)
export USER
DEVICE="@server_0"
CLIENT="@client_0"
NAME="pi8"
ARGS="-s -u -v"
while true; do
  # shellcheck disable=SC2086
  "/home/jeremy"/.local/bin/sshnpd -a "$DEVICE" -m "$CLIENT" -d "$NAME" $ARGS
  sleep 10
done

Pi sshnpd version:

jeremy@raspberrypi8:~ $ ~/.local/bin/sshnpd
Version : 3.4.2

MacOS v3.4.2 proof working fine:

jeremytubongbanua@Jeremys-Air sshnp % ./sshnp
Version : 3.4.2
-k, --key-file             Sending atSign's atKeys file if not in ~/.atsign/keys/
-f, --from (mandatory)     Sending (a.k.a. client) atSign
-t, --to (mandatory)       Receiving device atSign
-d, --device               Receiving device name
                           (defaults to "default")
-h, --host (mandatory)     atSign of sshrvd daemon or FQDN/IP address to connect back to
-p, --port                 TCP port to connect back to (only required if --host specified a FQDN/IP)
                           (defaults to "22")
-l, --local-port           Reverse ssh port to listen on, on your local machine, by sshnp default finds a spare port
                           (defaults to "0")
-s, --ssh-public-key       Public key file from ~/.ssh to be appended to authorized_hosts on the remote device
                           (defaults to "false")
-o, --local-ssh-options    Add these commands to the local ssh command
-v, --[no-]verbose         More logging
-r, --[no-]rsa             Use RSA 4096 keys rather than the default ED25519 keys
-u, --remote-user-name     username to use in the ssh session on the remote host
    --root-domain          atDirectory domain
                           (defaults to "root.atsign.org")
    --config-file          Read args from a config file
                           Mandatory args are not required if already supplied in the config file
    --list-devices         List available devices

Invalid argument(s): Option from is mandatory.
jeremytubongbanua@Jeremys-Air sshnp % ./sshnp -f @client_0 -t @server_0 -h @rv_eu -s id_ed25519.pub -d pi8
ssh -p 53454 jeremy@localhost -o StrictHostKeyChecking=accept-new -o IdentitiesOnly=yes -i /Users/jeremytubongbanua/.ssh/id_ed25519

Steps to reproduce

  1. First I '...'
  2. Then I '...'
  3. And then '...'

Expected behavior

v4.0.2 sshnp works with v3.4.2 sshnpd devices

Screenshots

No response

Smartphones

Were you using an atApplication when the bug was found?

No response

Additional context

No response

XavierChanth commented 11 months ago

@JeremyTubongbanua You have to use the --legacy-daemon flag, which there is a fix for on trunk branch.