dylankenneally / react-native-ssh-sftp

SSH and SFTP client library for React Native
https://www.npmjs.com/package/@dylankenneally/react-native-ssh-sftp
MIT License
11 stars 8 forks source link

[Enhancement request] update jsch to support ed25519 Key #22

Open raghulkrishna opened 1 month ago

raghulkrishna commented 1 month ago

Currently jsch package doesnt support ed25519 Key update the jsch to support them for android https://github.com/mwiede/jsch/tree/master

In ios only old rsa keys are supported not new rsa or ed25519 keys are supported

dylankenneally commented 1 month ago

Thanks for creating this enhancement request @raghulkrishna.

I'll need to investigate this a little further before replacing the JSch package, in particular I'll need to look at the impact of this comment and this comment from your suggested replacement package.

This is being used commercially for an app that configures IoT hardware, so let me look in to compatibility before proceeding.

csaben commented 1 month ago

@dylankenneally it's a drop in replacement in your build.gradle. mwiede made a blog post about it here.

originally, I was hitting Algorithm negotiation fail everywhere. After replacing

- api 'com.jcraft:jsch:0.1.55'
+ api 'com.github.mwiede:jsch:0.1.58'

in my node_modules in your app's build.gradle, everything works without adjusting any imports.

Thanks for maintaining this repo, it's been great so far!

raghulkrishna commented 1 month ago

@csaben were you able to use ed25519 keys

csaben commented 1 month ago

@csaben were you able to use ed25519 keys

just generated one with ssh-keygen -t ed25519 and tried but get an invalid key error again. So, unless I'm messing up somewhere else, no.

raghulkrishna commented 1 month ago

@csaben were you able to use ed25519 keys

just generated one with ssh-keygen -t ed25519 and tried but get an invalid key error again. So, unless I'm messing up somewhere else, no.

is this for ios or android?

raghulkrishna commented 1 month ago

@dylankenneally for ios here you have the latest libssh module in NMSSH https://github.com/aanah0/NMSSH

csaben commented 1 month ago

@csaben were you able to use ed25519 keys

just generated one with ssh-keygen -t ed25519 and tried but get an invalid key error again. So, unless I'm messing up somewhere else, no.

is this for ios or android?

android

dylankenneally commented 1 month ago

Thanks for your input @csaben and @raghulkrishna, I've updated both NMSSH and jsch based on your suggestions in release 1.5.18 (available on npm).

I'll leave this issue open for a couple of days to see if you have any feedback on this version.

raghulkrishna commented 1 month ago

@dylankenneally take a look at this https://github.com/raghulkrishna/react-native-ssh-sftp/blob/master/android/build.gradle

we need to add a dependency for android implementation 'org.bouncycastle:bcprov-jdk15on:1.70' to make ed25519 keys based auth work (this did not affect any of the old key types and sizes as well)

I am also testing key generation and key information https://github.com/raghulkrishna/react-native-ssh-sftp/blob/master/src/sshclient.ts This works only for android (i dont know how to update ios)

dylankenneally commented 1 month ago

@raghulkrishna thank you that.

I'd be more than happy to review & accept PR's for the changes you're suggesting if you would like to collaborate. I'd suggest sending seperate PR's if you're happy to:

  1. to get ed25519 keys based auth working
  2. for key generation and key information

This works only for android (i dont know how to update ios)

Re the above 👆, we could take your second PR for key generation to a feature branch, and I (or others) could take a look at the iOS part, or I could put some scaffolding in place for iOS as a stop gap.

Let me know your thoughts.

raghulkrishna commented 1 month ago

@dylankenneally i updated the changes here https://github.com/dylankenneally/react-native-ssh-sftp/pull/25/files it would be nice if you could implemement similar to ios